Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display variable type when hovering in Visual Studio

I'm using Visual Studio 2017 in C#. When hovering over a variable when the program is not running, a pop-up appears showing the variable type and name. However, when the program is running and hits a break-point, hovering only shows the name and value, but not the type. I would like it to display the type when the program is running as well.

For example, say I have the following code:

var foo = 100;

When the program is stopped and I hover over the variable foo, it displays (local variable) int foo. However, if I set a break-point right after that line, run the program, and then hover over it after hitting the break-point, it displays foo | 100. Is there a way to get it to show something like int foo | 100?

I've tried searching online and looked through the options provided in Tools > Options > Debugging, but I didn't find anything that looked like what I want.

like image 788
inejwstine Avatar asked May 04 '26 10:05

inejwstine


1 Answers

Is there a way to get it to show something like int foo | 100?

I'm afraid the answer is negative. The option which displays (local variable) int foo and that(DataTips) which displays foo | 100 are two different things.

VS use DataTips option to show the quick info during debug mode. For this option,it displays quick info about the variable when you hover over it, which doesn't support detailed type message like what you want: int foo | 100.

I recommend you use watch window to observe the value and type of variables.Select the variable you want, right-click and choose add watch to observe it. Or drag it to watch window when debugging to watch it.

Also, you can open a locals window to watch variables with type message in current scope.

like image 175
LoLance Avatar answered May 06 '26 05:05

LoLance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!