Namespace :

May 11, 2011
  • Namespace is logical division of class, structure and interface OR way to organize your Visual Basic .NET code is through the use of namespaces.
  • Namespaces are a way of grouping type names and reducing the chance of name collisions.
  • The namespace with all the built-in functionality comes under System namespace. All other namespaces comes under this System namespace.

Declaration of Namespaces:

// Namespace Declaration in C#
  • using System;
  • using System.Data;
// Namespace Declaration in VB
  • imports system;
  • imports system.Data;

Code Example :

namespace ExampleNamespace { class TestExample { public void ShowMessage() { Console.WriteLine("This is the TestExample namespace!"); } } }


  • We can establish security, version, reference, and deployment boundaries by using namespaces
  • Because of grouping of namespaces we can create hierarchy which is easy to identify classes by fully qualified names.