Chapter 7. Namespaces

Even if you did not realize it, you have been using namespaces since the beginning of this book. For example, System, System.Diagnostics, and System.Windows.Forms are all namespaces contained within the .NET Framework. Namespaces are an easy concept to understand, but this chapter puts the ideas behind them on a firm footing — and clears up any misconceptions you might have about how they are used and organized.

If you are familiar with COM, you will find that the concept of namespaces is the logical extension of programmatic identifier (ProgID) values. For example, the functionality of Visual Basic 6's FileSystemObject is now mostly encompassed in .NET's System.IO namespace, though this is not a one-to-one mapping. However, namespaces reflect more than a change in name; they represent the logical extension of the COM naming structure, expanding its ease of use and extensibility.

In addition to the traditional System and Microsoft namespaces (for example, used in things such as Microsoft's Web Services Enhancements), the .NET Framework 3.5 includes a way to access some tough-to-find namespaces using the My namespace. The My namespace is a powerful way of "speed-dialing" specific functionalities in the base.

This chapter about namespaces covers the following:

  • What namespaces are

  • Which namespaces are used in Visual Studio 2008 projects by default

  • How to reference namespaces and use the Imports statement

  • How the compiler searches for class references

  • How to alias namespaces ...

Get Professional Visual Basic® 2008 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.