In Visual Basic .NET, it is possible to declare aliases for namespaces, giving the possibility of using more concise declarations, if the developer desires to do so.
Let's see an example: Typically, the use of StringBuilder class could follow the following three declarative ways:
Without Imports statement
Let's see an example: Typically, the use of StringBuilder class could follow the following three declarative ways:
Without Imports statement
- Dim s As New System.Text.StringBuilder("test")
- s.Append("123")
This kind of implementation requires the developer to declare the "s" variable writing down the path to the desired class, in our case StringBuilder, contained into System.Text namespace.
With Imports statement
With Imports statement
- Imports System.Text
- ' ...
- Dim s As New StringBuilder("test")
- s.Append("123")
Using an Imports statement, the programmer can simply use the classes names, for the namespace(s) to be used will be declared at the beginning of the code.
Using Aliases
Using Aliases
- Imports sb = System.Text.StringBuilder
- '...
- Dim s As New sb("test")
- s.Append("123")
The Imports statement could be implemented with customized names. In the example above, I have stated that in the rest of the code, the class System.Text.StringBuilder will be redefined as "sb". So, we can declare a new StringBuilder with the function "New sb()", accessing the same constructors possessed by System.Text.StringBuilder, being sb a simple alias of the real thing.

Santhakumar MunuswamyPosted Oct 18, 2015, 3:19 AM
Good one
Priyaranjan K SPosted Oct 14, 2015, 12:20 PM
Nice Share ...
Mukesh KumarPosted Oct 14, 2015, 1:28 AM
Great work, thanks for sharing
Nilesh JadavPosted Oct 14, 2015, 12:08 AM
Good Work !!
Harshad PansuriyaPosted Oct 13, 2015, 11:55 PM
Nice one
Sujeet SumanPosted Oct 13, 2015, 1:57 PM
Nice Article...............