.NET Framework Namespaces
.NET Framework NamespacesWhat 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 were 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, youll find yourself referring to classes like this:
System.Data.OleDb.OleDbDataReader
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: Youd 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. Whats 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 youll 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梩hat would take
several books itself.
The task of limiting the classes to be discussed in this chapter was
daunting梩here are well over 1,000 classes provided by the .NET Framework.
We decided to focus on classes that youre 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 weve included is large but not
overwhelming. Once you understand some of these objects, working with other
objects is easier.
Heres a list of the namespaces covered in this chapter:
System
System.Data
System.Data.OleDb
System.Data.SqlClient
System.IO
System.Text
System.Collections
System.Web.Services
System.Windows.Forms
System.Xml
Although this seems like quite a lot of classes to cover, well 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.
TIP
In order to follow along with the discussion in this chapter, you can load
the JumpstartFrameworkClassesFrameworkClasses.sln solution into Visual
Studio .NET.
补充:Web开发 , ASP.Net ,