Namespaces

   

graphics/newterm.gif

As I mentioned earlier, the .NET Framework is composed of classes ”many 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 a 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 , for example, belong to the System.Windows.Forms namespace. Use Table 24.1 as a guide; if a certain namespace 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.CSharp Contains classes that support compilation and code generation using the C# language.
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 CLR 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.
graphics/bookpencil.gif

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.


   
Top


Sams Teach Yourself C# in 24 Hours
Sams Teach Yourself Visual Basic 2010 in 24 Hours Complete Starter Kit (Sams Teach Yourself -- Hours)
ISBN: 0672331136
EAN: 2147483647
Year: 2002
Pages: 253
Authors: James Foxall

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