Mark Smith

ASP.NET, SQL Server, HTML, CSS and other random thoughts!

Imports Alias

You know those things where you just think "How didn't I know that?!", well I got one today. I only just found out (laugh at me if you want!) that you can add an alias to an "Imports" statement. So, instead of typing:

Imports System.Data

I can type:

Imports d = System.Data

and refer to it as "d". Here's what it would look like in Visual Studio:

Alias 

Thanks to Christiaan Baes for the tip!
 

Comments

Imports Alias - Mark Smith said:

Pingback from  Imports Alias - Mark Smith

# October 11, 2007 8:23 AM

jayson knight said:

Old trick, however I strongly feel it leads to readability issues in larger classes.

# October 11, 2007 8:27 AM

Dave said:

I didn't know you could do it either but I don't like it. I agree with Jayson.

# October 11, 2007 12:32 PM

John said:

Only real usefulness of this would be similar to class instantiation.  In case you didnt want to do all the sub imports to other subnamespace/classes.  You could use this as a shortcut interrupt to those classes and namespaces.  But again, as stated above, that usefulness is far overweighted by the lack of control and if someone isnt smart enough to figure out the reference then it can lead to alot of confusion and mistakes.  Id like to see some implementation of the Abbreviated namespace reference like in C#.

# June 15, 2009 10:02 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)