Global Namespaces and the Global Keyword

A common scenario in .NET development is creating class libraries that will be reused in other projects or given (or sold) to other developers. In these situations, it is convenient defining one or more first-level namespaces that can expose types or other namespaces. However, when you create a new project, Visual Basic also defines the root namespace (refer to Figure 9.1 for an example). This implies that defining a custom namespace like this:

Namespace MyUtilities  Public Class Utility1    'Your implementation goes here...  End ClassEnd Namespace

causes the Visual Basic compiler to include the new namespace inside the root one whose name is, by default, the same as the ...

Get Visual Basic 2015 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.