如何在调试时“监视”VS 2015中(C#)方法的返回值?

时间:2016-03-17 08:15:01

标签: c# visual-studio debugging

推荐的副本是a)不是VS 2015特定的,b)接受的答案有明确的评论:

  

不幸的是,它似乎没有出现在VS2015(devenv v14)

所以我正在寻找如何在VS 2015中做到这一点?

---原来的问题是:----

在VS 2015中多次调试时,我想知道方法返回的实际值。 (如return <expression>;

在场景中我经常想不出比(停止),修改源代码和编写

更好
var result = <expression>;
return result; // and place a breakpoint here, and "watch" the result variable.

场景如:

  • <expression>很复杂,就像LINQ一样,有许多嵌入式函数,可能会评估它可能有副作用,或者只是迭代器不能多次迭代
  • ...或...尝试在观察窗口中以交互方式评估<expression>时调试器挂起
  • 在调用者方面,上下文不像x = y.MyMethod()那么简单,所以我可以在那里看到返回值(而不是评估MyMethod的返回值)

我只是想知道是否存在我缺少的内置方式,并设置断点(见下文)并以某种方式知道实际(已经评估过的)实际返回值?

    //...
    return <expression>;
} // place a beakpoint here and see what is the actual eveluated return value
// Maybe I am wrong, but I think it must be an point in time when the actual
// return value is already evaluated runtime so it is not an extreme idea to 
//allow to "watch" it for the developer.

0 个答案:

没有答案