JavaScript Editor JavaScript Editor     JavaScript Debugger

Previous Section Next Section

Main Page

Creating Namespaces

When you're creating a large number of classes, it can be helpful to divide them up into their own namespaces to help organize things. We already know about namespaces; as the name implies, you use them to create separate spaces so that names can't conflict with other names already declared. To create your own namespace, you can use the Namespace statement:

Namespace {name |}
End Namespace

Here are the parts of this statement:

  • name—Required. A unique name that identifies the namespace.

  • componenttypes—Required. Elements that make up the namespace. These include enumerations, structures, interfaces, classes, delegates, and so on.

Note that namespaces are always public, which means that the declaration of a namespace cannot include any access modifiers. (However, the components inside the namespace may have public or friend access; the default access is friend.)

Here's an example that declares two namespaces, one inside another:

Namespace Secret          ' Declares a namespace named Secret.
    Namespace TopSecret   ' Declares a namespace named TopSecret in Secret.
        Class Documents   ' Declares the class Secret.TopSecret.Documents
        End Class
    End Namespace
End Namespace
Previous Section Next Section

JavaScript Editor Free JavaScript Editor     JavaScript Editor