We help IT Professionals succeed at work.

VB.net Imported Name spaces

Murray Brown
Murray Brown asked

I am using third party software in Visual Studio and notice that although I have added references to their software that the relevant items are not ticked in the import name spaces at the bottom of the project references window. Should I check these boxes? Will it make it easier to use and how?
Watch Question

Most Valuable Expert 2011
Top Expert 2015
Importing a namespace means you don't have to "fully qualify" the type name within your code. For example whereas you can type this in your code:

System.Console.WriteLine("Hello World!")

Open in new window

Do you really want to type "System" every time you want to write to the console? Instead, we often do:

Imports System


Console.WriteLine("Hello World!")

Open in new window

This may seem trivial for this example, but when you start getting into deeper namespaces, then the savings becomes apparent (e.g. System.Collections.Generic).

As far as checking the boxes, that is up to you. You can either check the boxes, or you can put the "Imports" statement within each file that uses something from that namespace. I believe if you check the boxes, then the imports are application-wide, whereas putting them within each file makes the import applicable just to that file.
Murray BrownASP.net/VBA/VSTO Developer


thanks very much

Explore More ContentExplore courses, solutions, and other research materials related to this topic.