Export (0) Print
Expand All

6.4.1 Namespace Declarations

Visual Studio .NET 2003

A namespace declaration consists of the keyword Namespace followed by a qualified identifier and optional namespace member declarations. If the namespace name is qualified, the namespace declaration is treated as if it is lexically nested within namespace declarations corresponding to each name in the qualified name. For example, the following two namespaces are semantically equivalent:

Namespace N1.N2
    Class A
    End Class

    Class B
    End Class
End Namespace 

Namespace N1
    Namespace N2
        Class A
        End Class

        Class B
        End Class
    End Namespace
End Namespace

When dealing with the members of a namespace, it is not important where a particular member is declared. If two programs define an entity with the same name in the same namespace, attempting to resolve the name in the namespace causes an ambiguity error.

Namespaces are by definition Public, so a namespace declaration cannot include any access modifiers.

NamespaceDeclaration ::=
   Namespace QualifiedIdentifier LineTerminator
   [ NamespaceMemberDeclaration+ ]
   End Namespace LineTerminator

See Also

6.4.2 Namespace Members | 6.4 Namespaces | Namespace Statement (Visual Basic Language Reference) | Namespaces (Visual Basic Language Concepts)

Show:
© 2014 Microsoft