开发者

Can I auto-import a namespace in MS Visual Studio 2010?

开发者 https://www.devze.com 2023-02-15 10:58 出处:网络
When developing for Android in Eclipse, for example, it\'s easy to automatically import packages and classes by hitting Ctrl+Shift+O. I\'m finding it difficult to write code every time I have to go go

When developing for Android in Eclipse, for example, it's easy to automatically import packages and classes by hitting Ctrl+Shift+O. I'm finding it difficult to write code every time I have to go google a function to figure out its namespace ... is t开发者_StackOverflowhere an easier way?


Once you've added a dll as a reference, VS will suggest this as part of its intellisense feature. Type in the name, and then hover over it - there will be a blue (maybe it is red?) underline - and VS will give you an arrow to click that lets you add the namespace.

If it is a namespace you find yourself adding frequently, you can add it to your config so that you're not doing it in files across your project.

(I do have Resharper installed so I can't check this, but I'm pretty sure VS has this natively...)


There is Ctrl + Shift + F10 or Ctrl+ shortcut, that provides some light refactorings like creating method stubs, renames methods and variables and imports usings. This shortcut is not always available - it can be used when a small red box underneath, after you click it you'll see the drop-down menu with a choice of possible actions

Can I auto-import a namespace in MS Visual Studio 2010?


When you type in a class name, hit Ctrl + . a list would appear, then hit Enter on what you need

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号