What is a namespace? If Microsoft had simply provided a list of several thousand classes, attempting to find or work with any specific class would be next to impossible. Although we're speculating, Microsoft might have ended up using class names such as SystemDataOleDbDataSet and SystemTheadingThread. Long names would be required in order to provide some sort of groupings and perspective.
Instead, Microsoft chose to group the various classes into a hierarchical set of namespaces. Using a syntax that separates levels in the hierarchy with dots, you'll find yourself referring to classes like this:
In this example, the .NET Framework provides a System namespace, a System.Data namespace, and a System.Data.OleDb namespace. Each provides a set of classes, and the OleDbDataReader class is a part of the System.Data.OleDb namespace.
Imagine this scenario: You'd like to send a letter to a friend named Tom who lives across the country, and you address an envelope to Tom (just "Tom"), slap on a stamp, and drop it into a mailbox. What's the chance that the letter will get to your friend? Next to none. If the U.S. Postal Service had assigned each of us a local "namespace" consisting of postalcode.state.city.streetaddress, then you might address your letter to 90012.ca.los angeles.123 Smith Street and have it reach your friend. Microsoft faced the same sort of issue when developing the .NET Framework. Therefore, each class belongs to a single namespace, and you'll use the .NET Framework documentation to investigate the various classes and namespaces.
You are probably asking yourself, which namespaces will I use most often? This chapter discusses those namespaces you might utilize for typical Web- or Windows-based business applications. This chapter will not (nor could it) provide a full reference of every available namespace that would take several books itself.
The task of limiting the classes to be discussed in this chapter was daunting there are well over 1,000 classes provided by the .NET Framework. We decided to focus on classes that you're likely to use in applications that take advantage of Windows Forms, Web Forms, Web Services, databases, and XML. By using these rather broad areas as the basis for choosing the namespaces, the list of classes we've included is large but not overwhelming. Once you understand some of these objects, working with other objects is easier.
Here's a list of the namespaces covered in this chapter:
Although this seems like quite a lot of classes to cover, we'll only provide a brief introduction to them in this chapter. You will find more coverage of many of these namespaces in later chapters in the book.
In order to follow along with the discussion in this chapter, you can load the Jumpstart\FrameworkClasses\FrameworkClasses.sln solution into Visual Studio .NET.