Visual basic auto import import spaces

In C #, some default namespaces, such as System.Collections, are listed without input using blah. In the visual base, they are not imports. Is there a way to get vb to automatically import some default namespace or does VB work differently than C #?

+2
source share
3 answers

I think the first element posted by John Rudy is what you are looking for - add them to your project properties.

However, VB.Net also works differently than C #, since in VB this means that importing a namespace requires a different matter than in C #. When you import a namespace into VB, it also provides child namespaces in scope.

Take, for example, the namespace Systemthat is imported by default. Since the System namespace is imported, you do not need to first enter System.to refer to a child namespace, such IOas in C #. So, right out of the box, you can say something like this in VB:

If IO.File.Exists(MyFile) Then ....

It is simply not possible in C # right now. You also need to import System.IOand then just say File.Exists()or specify the System: namespace as well System.IO.File.Exists().

, VB , , . , , VB, #.

+4

, . :

  • VB?
  • #?

# 1, , . , Visual Studio 2005 , "". - " " .

# 2, , . Visual #.

+3

I don't think Visual Studio does this by default for C # or VB.

However, the Jetbrains Resharper plugin automatically imports namespaces for you, in the same way that Eclipse does when you use CTRL + SHIFT + O.

0
source

Source: https://habr.com/ru/post/1733546/


All Articles