My Profile

Wednesday, January 26, 2011

Importing a Namespace

If a class is present under a namespace, must and should the class has to be referred by prefixing with the namespace under which it was defined. which will be complicated because some time we have very lengthy namespaces. To overcome the problem we can import a namespace into a program and consumes the classes in it without the namespace prefix.

To import a namespace, we use

  • using statement in CSharp and
  • imports statement in VB.

Note: Importing of a namespace should be done on the top of the class.


                                  using <namespace> ;

                                  eg;  using System;


using System;
class ImportsDemo

    static void Main()


        Console.WriteLine("Importing a namespace");




** If you like this post please like our page in facebook "Dot Net Support


Post a Comment


Twitter Delicious Facebook Digg Stumbleupon Favorites More