Creating Alias name for namespace

The namespaces in .NET can be very long and less obvious.

And to refer the class of the name space we need to include the entire path.

There is a way to simplify this by creating your own alias for the namespace.

How to do?

You can use the Imports statement (VB.NET) or using directive (C#) with an assignment operation.



Imports < AliasName > = < NameSpace >


Using < AliasName > = < NameSpace >

Example - VB

Imports MyaliasName = Microsoft.VisualBasic

Example - C#

Using MyaliasName = Microsoft.VisualBasic;

That way, you can refer to specific class elements within the class referred to using the variable you created in the assignment operation.


Private Sub TestFunction()

MyaliasName.MsgBox("I am Alias")

End Sub

// C#

void TestFunction()


MyaliasName.MsgBox("I am Alias");



Author: nimesh25 Jul 2009 Member Level: Bronze   Points : 0


It's really nice.

Discribe more.


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: