• 0

[C#] Automatically add "using"?


Question

Hello. In NetBeans, there is a function to let the IDE to manage references to different packages automatically.

85431370.png

For example, if I have "Scanner" type of object in my code, when I press Fix Imports, NetBeans will automatically add "import java.util.Scanner;".

I want to know if Visual Studio has similar functions?

Thanks. :)

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
I want to know if Visual Studio has similar functions?

Thanks. :)

In Visual Studio when your cursor is on the word you want resolved, hit ctrl + .

post-263632-1257345681.png

Then it will let you pick from adding the using statement or changing your object to a full named reference.

Link to comment
Share on other sites

  • 0

^ As Ottsca said, VS can resolve those issues for you.

I also use Resharper which I feel is better at highlighting and managing your using statements.

Link to comment
Share on other sites

  • 0
In Visual Studio when your cursor is on the word you want resolved, hit ctrl + .

post-263632-1257345681.png

Then it will let you pick from adding the using statement or changing your object to a full named reference.

yep, do this :)

Link to comment
Share on other sites

  • 0
In Visual Studio when your cursor is on the word you want resolved, hit ctrl + .

post-263632-1257345681.png

Then it will let you pick from adding the using statement or changing your object to a full named reference.

Keep in mind that this only works if proper references have been added to the assembly. Also if there are more than 1 objects of the same name then it gets confused. But in most of the cases it does work pretty well.

Link to comment
Share on other sites

  • 0
Keep in mind that this only works if proper references have been added to the assembly. Also if there are more than 1 objects of the same name then it gets confused. But in most of the cases it does work pretty well.

One of the things I love about resharper, sometimes it can highlight that you may need to reference a specific assembly. Not sure just how expansive this feature is, but its a welcome one!

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.