在Visual Studio中的方法的返回行上检查函数的返回值 [英] Inspecting the returned value of a function on the return line of a method in Visual Studio
问题描述
我有一行这样的代码
return foo(barIn);
如果我放置一个断点,我可以检查foo(barIn)的返回值,进入foo?我可以将代码重写为
var result = foo(barIn);
返回结果;
但是我想要方便不重写,而不是摆脱当前的代码。 p>
==========编辑==========
四个初始答案很有趣(谢谢),但他们并没有真正回答我的问题。让我尝试更清楚。
在这种方法中
public string functionA()
{
return functionB();
}
是否有一种方法在Visual Studio 2012中放置一个断点return functionB();并检查functionB的返回值,而不必进入函数B,重新运行函数B或重写函数A.
不,你不能满足这个确切的行为。请参阅我可以找到在Visual Studio中进行调试时返回值返回值。最接近的是:
如果 foo
是幂等的(即它没有任何副作用) ,那么您可以在 foo(barIn)
中添加一个手表。
如果 有副作用,则将断点放在 return
,然后默认退出( Shift + F11 )并检查该函数的结果分配给的变量。
I have a line of code like this
return foo(barIn);
If I place a breakpoint on the line can I inspect the returned value of foo(barIn) without stepping into foo? I can rewrite the code to
var result = foo(barIn);
return result;
but I'd like the convenience of not rewriting and not stepping away from the current code.
========== EDIT ==========
The four initial answers are interesting (thanks) but they do not actually answer my question. Let me try to be clearer.
In this method
public string functionA()
{
return functionB();
}
is there a way in Visual Studio 2012 to place a break point on the line "return functionB();" and inspect the return value of functionB without stepping into functionB, re-running functionB, or rewriting functionA?
No, you cannot meet this exact behaviour. See Can I find out the return value before returning while debugging in Visual Studio. The closest you can get is:
If foo
is idempotent (i.e. it does not have any side-effects), then you can add a watch to foo(barIn)
.
If it does have side-effects, then put your breakpoint on the return
, and then step-out (Shift+F11 by default) of the function and inspect the variable that the result of the function is assigned to.
这篇关于在Visual Studio中的方法的返回行上检查函数的返回值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!