C#/.NET How do I find the containing namespace fro

2019-06-16 20:35发布

I often find myself remembering the name of a class that I want to use, but not remembering the containing namespace. Apart from searching the web, i wonder if a good method exists for looking this up.

8条回答
虎瘦雄心在
2楼-- · 2019-06-16 20:56

I think if you press ALT, SHIFT and F10 in Visual Studio - intellisense will drop down an option for you to add the name space of the class you have just typed.

查看更多
放我归山
3楼-- · 2019-06-16 20:58

You can always hang a big poster on your cube wall like me.

3.5 NameSpace

查看更多
淡お忘
4楼-- · 2019-06-16 20:58

Two ways that work in Visual Studio 2013:

  • Right-click and select "Resolve".
  • Hover over the class and a 'Options to help bind the selected item' box will appear (same as Ctrl + '.' or Alt+Shift+F10)

Select the namespace and it will insert it for you.

查看更多
看我几分像从前
5楼-- · 2019-06-16 20:59

CTRL + '.' will bring up a menu where you can either add a 'using' or fully qualify the class.

查看更多
叼着烟拽天下
6楼-- · 2019-06-16 21:06

Use the search function in .NET Reflector by Red Gate Software.

查看更多
贪生不怕死
7楼-- · 2019-06-16 21:07

You can right click and select "Go To Definition" in VS and this will either load the class definiftion in your solution or it will show a metadata view of the class definition using reflection. Either of those should have the namespace defined near the top of the page.

If you need to add the namespace with a using decliration right click the unresolved class and mouse over to resolve. It will show you a list of namespaces that contain that class and selecting one will generate the using statement.

查看更多
登录 后发表回答