Using Fully Qualified Names
Visual Studio .NET 2003
Namespaces and types have unique names, which are described by fully qualified names that indicate a logical hierarchy. For example, A.B is the name of the namespace or type B nested in the namespace or type A.
In the following code segment, there are nested classes and namespaces. The fully qualified name is indicated as a comment following each entity.
namespace N1 // N1
{
class C1 // N1.C1
{
class C2 // N1.C1.C2
{
}
}
namespace N2 // N1.N2
{
class C2 // N1.N2.C2
{
}
}
}
In the preceding code segment:
- The namespace
N1is a member of the global namespace. Its fully qualified name isN1. - The namespace
N2is a member ofN1. Its fully qualified name isN1.N2. - The class
C1is a member of theN1. Its fully qualified name isN1.C1. - The class name
C2is used twice in this code. However, the fully qualified names are unique. The first one is declared insideC1; thus its fully qualified name is:N1.C1.C2.The second is declared inside a namespaceN2; thus, its fully qualified name isN1.N2.C2.
Using the preceding code segment, you can add a new class member C3 to the namespace N1.N2 as follows:
namespace N1.N2
{
class C3 // N1.N2.C3
{
}
}
For more information on namespaces, see Namespaces.