NomenNescio
NomenNescio

Reputation: 3030

Visual studio debugging view last statement in method?

I'd like to know how to debug the last statement in a method? For example, let's say I have the following statement method:

private void doSomething()
{
  int x = 5;
  int y = x + 4;
  int z = y * 2;
}

If I but the breakpoint at the start of the method and step trough the method, I can see the result of x, the result of y, but not the result of z, how can I see the result of z while debugging?

EDIT: Apparently this value is being skipped because it isn't significant to the program but while it might not be significant for the final program but it is significant while debugging & testing and highly annoying when I have to add dummy statements for these kind of things.

Upvotes: 1

Views: 284

Answers (2)

Hardryv
Hardryv

Reputation: 793

Once you're debugging and code-processing halts, right-click on 'z' (or whatever variable you want to observe) and select "Add Watch".

This should open up a 'Watch' tab where you can observe what happens to any values you have an interest in, step-by-step and line-by-line.

Upvotes: 0

Luchian Grigore
Luchian Grigore

Reputation: 258548

You can set a breakpoint at the closing bracket }. z should be available there. Or you could multiply y by 2...

Upvotes: 3

Related Questions