Name Clashes Due to Imports

Because namespaces were invented to resolve name clashes in some flat global namespace (for example, as seen in Win32), they allow for types with the same (short) name to exist in different namespaces existing alongside each other. When multiple such namespaces containing a type with the same name are imported, a conflict will occur when trying to refer to that particular type.

For example, when adding references to both System.Drawing and WindowsBase (the former of which is used by Windows Forms and the latter by Windows Presentation Foundation), multiple definitions of a Point type exist (among many others, such as Size). Figure 24.10 shows the Resolve feature in Visual Studio that can be used to resolve a type name ...

Get C# 5.0 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.