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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.