Automatic namespaces import

2019-03-09 18:55发布

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?

3条回答
女痞
2楼-- · 2019-03-09 19:35

Look at JetBrain's excellent ReSharper product. It does this for you.

查看更多
男人必须洒脱
3楼-- · 2019-03-09 19:51

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:

Enter image description here

查看更多
何必那么认真
4楼-- · 2019-03-09 19:51

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.

查看更多
登录 后发表回答