[英]Contextual code generation in Visual C# 2008?
I type 我输入
ArrayList memberNames = new ArrayList() { "Jim", "John", "George" };
and Visual Studio tells me "ArrayList" cannot be found so I have to manually go to the top of the file and type 并且Visual Studio告诉我找不到“ ArrayList”,因此我必须手动转到文件顶部并键入
using System.Collections;
Is there a way to get Visual Studio to do this automatically? 有没有办法让Visual Studio自动执行此操作?
In FlashDevelop, for instance, you press CTRL-SHIFT-1 and it automatically generates these missing references, a nice feature. 例如,在FlashDevelop中,按CTRL-SHIFT-1它将自动生成这些缺少的引用,这是一个不错的功能。
SHIFT-ALT-F10 Will activate the Smart Tag on the class, which will give you the options "using System.Collections", and "System.Collections.ArrayList". SHIFT-ALT-F10将激活类的智能标记,这将为您提供“使用System.Collections”和“ System.Collections.ArrayList”选项。 It's typically two keystrokes to add a using.
添加使用通常是两次击键。
Edit: Seems I had a mangled keyboard profile. 编辑:似乎我有一个损坏的键盘配置文件。 Updated the key combo to the default.
将按键组合更新为默认值。 Thanks to Alan for pointing it out.
感谢艾伦指出。
Alt + Shift + F10 brings up a pop-up menu with "using System.Collections", and "System.Collections.ArrayList". Alt + Shift + F10会弹出一个弹出菜单,其中包含“使用System.Collections”和“ System.Collections.ArrayList”。
If you want to find a keyboard shortcut, choose Tools: Options and navigate down to Environment: Keyboard. 如果要查找键盘快捷键,请选择“工具”:“选项”,然后向下导航至“环境:键盘”。 However, it can be a challenge to figure out what they've called the thing you're looking for.
但是,弄清楚他们正在寻找的东西可能是一个挑战。 (The one you asked about is obviously View.ShowSmartTag, right?)
(您问的显然是View.ShowSmartTag,对吧?)
Update: From comments and other posts, I just learned that Ctrl + . 更新:从评论和其他帖子中,我刚刚了解到Ctrl + 。 also brings up the same menu.
也调出相同的菜单。 I guess not all the keyboard shortcuts appear in the keyboard options dialog.
我猜不是所有的键盘快捷键都出现在键盘选项对话框中。
CTRL+. CTRL +。 also activates the Smart Tag, which might be more intuitive.
还会激活智能标签,这可能更直观。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.