Even if you didn’t realize it, you’ve been using namespaces since Chapter 2. 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’re familiar with COM, you’ll 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 are about 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), .NET Framework 2.0 introduces a new way to get at some tough-to-find namespaces using the new My namespace. The My namespace is a powerful way of “speed-dialing” specific functionalities in the base.
This chapter covers the following:
What namespaces are
Which namespaces are used in Visual Studio 2005 projects by default
Referencing namespaces and using the Imports statement
How the compiler searches for class references
How to alias namespaces
Creating your own namespaces
Using the new My namespace