
The Role of .NET Namespaces
The FCL organizes its huge set of services using a concept called namespaces. A namespace is a logical,
hierarchical organization of types similar to Java packages. All .NET types “live” in a namespace. To use a
type, you must refer to it using its fully qualified name (i.e., including the namespace). The FCL defines a large
number of namespaces that contain a ton of services usable from all .NET languages.
You can access a type defined within a namespace in a couple different ways. You can use the fully qualified
type name, e.g., namespace.typename.
For example, the Console class lives in the System namespace:
Class TesterMain
Shared Sub Main()
'Namespace.TypeName.Method
System.Console.WriteLine("Hello world")
End Sub
End Class
Since typing namespaces is tedious, most .NET languages provide a shortcut mechanism.
VB has an 'Imports' keyword:
Imports System
Imports System.Drawing
Imports System.Collections
C# has a 'using' keyword (note the case and semicolon):
using System;
using System.Drawing;
using System.Collections;
Here is an example:
Imports System
Imports System.Collections
Namespace Test
Class TesterMain
Shared Sub Main()
'Use the System.Console class
Console.WriteLine("Hello world")
'Use the System.Collections.ArrayList class.
Dim myList As ArrayList
myList = New ArrayList()
End Sub
End Class
End Namespace
Here is a partial list of some of the core .NET namespaces.
System
Contains numerous types dealing with primitive data, mathematical manipulations, garbage collection,
and whatnot.
System.Collections
System.Collections.Generics
Defines a number of container types.
System.Data
System.Data.OracleClient
System.Data.SqlClient
Contains types for database interaction.
System.Drawing
System.Drawing.Printing
Contains numerous classes wrapping GDI+ primitives such as bitmaps, fonts, icons, printing support,
and advanced rendering classes.
System.IO Contains types for streaming IO to a variety of devices, including files.
System.Reflection
Contains types that provide runtime type discovery.
System.Runtime.InteropServices Provides facilities to interact with unmanaged code (e.g., Win32
DLLs and COM servers).
System.Security Contains types dealing with permissions, cryptography, and so on.
System.Threading Provides types for spawning and controlling threads.
System.Web Contain numerous types specifically geared towards the development of web
applications, including ASP.NET.
System.Windows.Forms Provides types that facilitate the construction of more traditional Win32
windows, dialog boxes, and custom widgets.
Your real challenge as a .NET developer is to learn about the wealth of types that ship with the .NET base class
libraries. MSDN (your local help system, which is also available online) has a specific book that describes
each and every namespace (and all the contained types. Look up the ".NET Framework Class Library" book
for full details.
Copyright (c) 2008. Intertech, Inc. All Rights Reserved. This information is to be used exclusively as an
online learning aid. Any attempts to copy, reproduce, or use for training is strictly prohibited.
.NET Name Spaces
Table of Contents
Courseware
Training Resources
Tutorials