• 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
https://www.neowin.net/forum/topic/841908-c-automatically-add-using/
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.

  • 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.

  • 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!

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

    • No registered users viewing this page.
  • Posts

    • If you are willing to go to approx $200, then as mentioned in your other thread I think a refurbished Pixel 8 will be a great deal that will last you for years. I recently recommended that to someone at work, he was on a strict £200 budget, which got him an excellent conditioned refurbished Pixel 8 here. He's since told me its the best phone he's ever had and feels its a massive upgrade over his old Samsung A series device. I don't know the sites which deal in refurbished devices in the US, however I’m sure you will have some options like we do here. Failing that Ebay is also quite good in my experience. If you wanted something a bit cheaper, then you could maybe go for an older Pixel 7, these will still get security updates until the end of 2027. Even after that you have good third party OS support from LineageOS. It doesn't have to be a Pixel though, you can buy many older devices for a good deal that would be better than a new $100 phone and flash LineageOS to them: https://wiki.lineageos.org/devices/
    • I don't use one drive, but then I don't use any cloud storage, not even Icloud on my mac. If I did use cloud storage, then I would not use One drive, not because there is anything wrong with it, but because I can use Icloud. The only reason I see to use one drive is if your job requires you to have access to it
    • Not built in, which is not a bad thing. There are ways of adding cloud storage to it, Dropbox is the most well know that also have a client for Linux, but there are others.
    • My advice, dont use teams, use the web version if possible. https://teams.microsoft.com/v2/
  • Recent Achievements

    • Collaborator
      WndSks went up a rank
      Collaborator
    • One Month Later
      Sopa flores earned a badge
      One Month Later
    • First Post
      StaticMatrix earned a badge
      First Post
    • Week One Done
      StaticMatrix earned a badge
      Week One Done
    • Rookie
      lamborghiniv10 went up a rank
      Rookie
  • Popular Contributors

    1. 1
      +primortal
      506
    2. 2
      PsYcHoKiLLa
      209
    3. 3
      +Edouard
      152
    4. 4
      Steven P.
      89
    5. 5
      ATLien_0
      79
  • Tell a friend

    Love Neowin? Tell a friend!