ECMA-334: 10.8.2 Fully qualified names
Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio
| C# Language Specification |
|
| © 2006 ECMA International |
10.8.2 Fully qualified names
Every namespace declaration and type declaration has a fully qualified name, which uniquely identifies the
namespace or type amongst all others. The fully qualified name of a namespace or type declaration with
unqualified name N is determined as follows:
- If the declaration is contained directly in a compilation unit and not nested in any other declaration, its fully qualified name is
N.
- Otherwise, its fully qualified name is
S.N, whereSis the fully qualified name of the immediately enclosing namespace or type declaration.
In other words, the fully qualified name of a declaration is the complete hierarchical path of identifiers (and generic-dimension-specifier (§14.5.11)) that lead to the type or namespace, starting from the global namespace. The fully qualified name of a declaration shall uniquely identify the namespace, non-generic type or generic instance type (§25.1.2) associated with the declaration. It is a compile-time error for the same fully qualified name to refer to two distinct entities. In particular:
- It is an error for both a namespace declaration and a type declaration to have the same fully qualified name.
- It is an error for two different kinds of type declarations to have the same fully qualified name (for example, if both a struct and class declaration have the same fully qualified name).
- It is an error for a type declaration without the
partialmodifier to have the same fully qualified name as another type declaration (§17.1.4).
[Example: The example below shows several namespace and type declarations along with their associated fully qualified names.
class A {} // A namespace X // X { class B // X.B { class C {} // X.B.C } namespace Y // X.Y { class D {} // X.Y.D } } namespace X.Y // X.Y { class E {} // X.Y.E class G<T> // X.Y.G<> { class H {} // X.Y.G<>.H } class G<S,T> // X.Y.G<,> { class H<U> {} // X.Y.G<,>.H<> } }
end example]