Creating Alias name for namespace

Posted by VIJI Sunday, July 5, 2009

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");


0 Responses to Creating Alias name for namespace

Post a Comment