问题
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.
回答2:
There is also a keyboard shortcut that will show you. Put the cursor over var
and type:
ctrl+k, i
回答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