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#?
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
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
System
namespace, 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.IO
and 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#.
I'm not sure what you're asking. I can see potentially two questions there:
For #1, yes you can. Assuming Visual Studio 2005 or higher, go into your project properties, and select the References tab. The auto-imports are listed under "Imported Namespaces" at the bottom of the view.
For #2, not that I'm aware of. I've never seen that behavior in Visual C#.
I don't believe Visual Studio does this by default for C#or VB.
However, the Jetbrains Resharper plugin will auto import namespaces for you, in the same that Eclipse does when you use CTRL+SHIFT+O.