Name Clashes Within Namespaces

The “construct” on which the C# compiler operates when turning code into an assembly is called a compilation unit, which in practice maps to a code file. All of those units are processed together, almost as if it were one large file containing all the declarations made in the code.

Multiple occurrences of the same namespace are just fine. In more official terms, the language considers namespaces open ended. Other compilation units processed by the compiler are free to add more declarations to a namespace:

image

When multiple types with the same name are declared in the same namespace, it results in an error, as illustrated ...

Get C# 4.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.