Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 396
Enrico Murru Avatar asked Oct 09 '08 11:10

Enrico Murru


People also ask

How to Auto import namespace Visual Studio?

You can turn this option on in Tools > Options > Text Editor > C# > Intellisense. If you select a suggested type from the intellisense list the necessary import is automatically added to your file.

How to import class in Php storm?

Import a class by using a quick fixPress Alt+Enter and accept the suggestion to import the namespace where the declaration of the class is detected. PhpStorm inserts a namespace declaration statement ( use statement).


1 Answers

Yes, Visual Studio 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 it's fewer keys and the . and Enter are closer.

like image 157
mattlant Avatar answered Oct 17 '22 05:10

mattlant