Monday, February 21, 2011

Automatic namespaces import

Is there a way in Visual Studio (a hotkey) to automatically import a type (or choosing between known namespaces) like the CTRL+O in Eclipse?

From stackoverflow
  • Look at JetBrain's excellent Resharper product. It does this for you.

  • When the red caret appears at the end of your member, just hit SHIFT+ALT+F10, then use arrows keys to choose the right option.

    Andrew : That doesn't automatically add the right 'using' declaration though. Resharper will.
    Enreeco : tried and never seen. thnks
    controlbreak : Seems buggy under VB.NET :-/
  • Yes, VS.NET Can add the using for you. When you type in a class name, hit CTRL + . and then enter (the first option is 99.99% the right one, so just hit enter). and you can have it add the using at the top of the file for the namespace of that class. I use it all the time.

    This is easier than shift alt f10 + enter as its les keys and the . and enter are closer.

    controlbreak : Yeah, CTRL + . is shorter - Thanks for the tip. Sounds buggy too in VB.NET

0 comments:

Post a Comment