If stepping through using a debugger and I have a block of code like the following
return int Foo()
{
return Bar();
}
Is there any way in the debugger to find out the result of Bar
before Foo
returns with the result?
If stepping through using a debugger and I have a block of code like the following
return int Foo()
{
return Bar();
}
Is there any way in the debugger to find out the result of Bar
before Foo
returns with the result?
If Bar()
has no side effects, just evaluate (run) it in a quick watch window.
Otherwise, if it does have side effects, if you can rewrite the code, write it as
return int Foo()
{
var bar = Bar();
return bar;
}
and put a break point on the return.
would consider using Command Window
? This can be found on
View => Other Windows => Command Window
and type
? Bar()
you will be able to see the result of Bar()
without even stepping Foo()
You could call Bar() and store the result in a variable and then simply output it. Otherwise you could add a breakpoint and use visual studio's step over functionality to go through the code and variable values line by line.