Namespaces


As mentioned earlier in this book, the .NET Framework is composed of classesmany classes. Namespaces are the method used to create a hierarchical structure of all these classes, and they help prevent naming collisions. A naming collision occurs when two classes have the same name. Because namespaces provide a hierarchy, it's possible to have two classes with the same name as long as they exist in different namespaces. Namespaces, in effect, create scope for classes.

The base namespace in the .NET Framework is the System namespace. The System namespace contains classes for garbage collection (discussed shortly), exception handling, data typing, and so much more. The System namespace is just the tip of the iceberg. There are literally dozens of namespaces. Table 24.1 lists some of the more common namespaces, many of which you've used in this book. All the controls that you've placed on forms and even the forms themselves belong to the System.Windows.Forms namespace. Use Table 24.1 as a guide; if a certain name-space interests you, I suggest that you research it further in the Visual Studio .NET online help.

Table 24.1. Commonly Used Namespaces

Namespace

Description

Microsoft.VisualBasic

Contains classes that support compilation and code generation using the Visual Basic language.

System

Contains fundamental classes and base classes that define commonly used value and reference data types, event handlers, interfaces, attributes, and exceptions. This is the base namespace of .NET.

System.Data

Contains classes that constitute the ADO.NET architecture.

System.Diagnostics

Contains classes that enable you to debug your application and to trace the execution of your code.

System.Drawing

Contains classes that provide access to the Graphical Device Interface (GDI+) basic graphics functionality.

System.IO

Contains classes that allow reading from and writing to data streams and files.

System.Net

Contains classes that provide a simple programming interface to many of the protocols found on the network.

System.Security

Contains classes that provide the underlying structure of the common language runtime security system.

System.Web

Contains classes that provide interfaces that enable browser/server communication.

System.Windows.Forms

Contains classes for creating Windows-based applications that take advantage of the rich user interface features available in the Microsoft Windows operating system.

System.XML

Contains classes that provide standards-based support for processing XML.


By the Way

All Microsoft-provided namespaces begin with either System or Microsoft. Other vendors can provide their own namespaces, and it's possible for you to create your own custom namespaces as well, but that's beyond the scope of this book.





Sams Teach Yourself Microsoft Visual C# 2005 in 24 Hours, Complete Starter Kit
Sams Teach Yourself Visual C# 2005 in 24 Hours, Complete Starter Kit
ISBN: 0672327406
EAN: 2147483647
Year: N/A
Pages: 248
Authors: James Foxall

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net