SUMMARY

Namespaces are everywhere in Visual Basic. Every piece of code you write is contained in some namespace, even if it is only the application’s root namespace. Despite the pervasiveness of namespaces, many developers never need to use them explicitly, so they find them somewhat mystifying.

Namespaces are really quite simple, however. They merely divide programming items into a hierarchy. They enable you to categorize related items and resolve name collisions in different parts of the application.

You can use the Imports statement to allow the program to refer to items in a namespace without giving fully qualified names. A namespace alias lets you explicitly specify an item’s namespace in an abbreviated form. This is particularly useful for resolving ambiguous names that appear in more than one namespace included by Imports statements.

This chapter described namespaces in general. Chapter 25, “Collection Classes,” describes some of the useful classes for grouping object classes, including those in the System.Collections and System.Collections.Generic namespaces.

Get Visual Basic 2012 Programmer's Reference 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.