See the type of a var in Visual Studio

本秂侑毒 提交于 2020-12-04 19:52:39

问题


Is there a way to see the type of a var within the Visual Studio 2013 code editor?

When I have a crazy linq query it would be nice to see what the resulting type will be. I don't want to replace the var keyword with the actual type, I just want to see what it is.


回答1:


You can get it by Hovering on particular var keyword.

For example see in below image the tooltip shows the details.

enter image description here




回答2:


There is also a keyboard shortcut that will show you. Put the cursor over var and type:

ctrl+k, i

enter image description here




回答3:


Hover your mouse over the var keyword, it will show it in a tootlip.




回答4:


The text of the type can often be obtained (using copy and paste) by temporarily changing the var to an explicit type, say int. That will force a compilation error. After doing a Build solution the type of the variable should be written in both the Error list and the Output panes.




回答5:


Move your mouse cursor hover the var keyword, a tooltip will show you the actual type.




回答6:


Hover on the variable... It will tell you.




回答7:


Add a variable watch. Check the type in the watch window.



来源:https://stackoverflow.com/questions/26137511/see-the-type-of-a-var-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!