In C# some of default name space such as System.Collections are listed without typing in using blah. In visual basic, they are not imports for you. Is there a way to force vb to auto imports some of default name space or VB work differently than C#?
In C# some of default name space such as System.Collections are listed without typing
Share
I think the first item posted by John Rudy is what you’re looking for- add them in the project properties.
However, VB.Net does also work differently than C#, in that it means a different thing in VB to import a namespace than it does in C#. When you import a namespace in VB, it also brings child namespaces ‘in scope’, in a manner of speaking.
Take the
Systemnamespace, for example, which is imported by default. Because the System namespace is imported, you don’t have to first typeSystem.to reference a child namespace likeIO, like you would in C#. So, right out of the box you can say something like this in VB:That just isn’t possible in C# right now. You either have to also import
System.IOand then just sayFile.Exists()or list out the System namespace as well:System.IO.File.Exists().It may not seem very significant, but you really get used to this VB feature after a while, and it comes in handy more than you’d think. I bring all this up because the end result of this feature is that you often don’t want to import as many namespaces in VB as you do in C#.