Daniel Williams
Daniel Williams

Reputation: 9304

How to get debugger to show unused variables in visual studio?

I don't know what setting was changed, but when I step through code in the debugger I no longer see variables that are not used.

For example, if I declare a variable and do not subsequently use it, as in:

i=10;

Then the debugger will not let me mouse over and see the value of i.

This is exactly the question asked here, but that question was not specifically answered!

And by specifically I mean to ask- how do you disable optimization? I never consciously turned it off.

In my solution Project Properties->Build->Optimize Code is OFF.

Upvotes: 3

Views: 2348

Answers (1)

Raymond Chen
Raymond Chen

Reputation: 45173

The question was answered. The optimizer removed the unused variable, so it no longer exists. You can't see the value of something that doesn't exist. Disable optimization.

Upvotes: 2

Related Questions