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
{
 public static void Main()
 {

   // Namespace.TypeName.Method

   System.Console.WriteLine("Hello world");   
 }
}



Since typing namespaces is tedious, most .NET languages provide a shortcut mechanism.

C# has a 'using' keyword (note the case and semicolon):


using System;
using System.Drawing;
using System.Collections;


VB has an 'Imports' keyword (note the lack of a semicolon):


Imports System
Imports System.Drawing
Imports System.Collections

Here is an example:


using System;
using System.Collections;


namespace Test
{
 class TesterMain
 {
   public static void Main()    
   {

     // Use the System.Console class

     Console.WriteLine("Hello world");

     // Use the System.Collections.ArrayList class.

     ArrayList myList;
     myList = new ArrayList();   
   }      
 }
}



Here is a partial list of some of the core .NET namespaces.



















































 







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.
.NET Name Spaces
Table of Contents
C# Tutorial | C#.NET Tutorial | Namespaces Tutorial

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.
Courseware
Training Resources
Tutorials

    

     Namespace


    Meaning in Life

  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.

Services