visual-studio 自动命名空间导入

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/186895/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 09:43:50  来源:igfitidea点击:

Automatic namespaces import

visual-studioimportkeyboard-shortcutshotkeys

提问by Enrico Murru

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

Visual Studio(热键)中是否有办法自动导入类型(或在已知命名空间之间进行选择),例如Eclipse 中的Ctrl+ O

采纳答案by Larry

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:

当您的成员末尾出现红色插入符号时,只需点击Shift+ Alt+ F10,然后使用箭头键选择正确的选项:

Enter image description here

在此处输入图片说明

回答by mattlant

Yes, Visual Studio can add the usingfor 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 usingat the top of the file for the namespace of that class. I use it all the time.

是的,Visual Studio 可以using为您添加。当你输入一个类名时,点击Ctrl+.然后Enter(第一个选项是 99.99% 是正确的,所以只需点击Enter)。您可以让它using在该类的命名空间的文件顶部添加。我用它所有的时间。

This is easier than Shift+ Alt+ F10+ Enteras it's fewer keys and the .and Enterare closer.

这比Shift+ Alt+ F10+更容易,Enter因为它的键更少,并且.Enter更接近。

回答by Andrew

Look at JetBrain'sexcellent ReSharperproduct. It does this for you.

看看JetBrain出色的ReSharper产品。它为你做这件事。