在 Visual Studio 中调试时,我可以在返回之前找出返回值吗?

问题描述:

采用以下函数:

DataTable go() {
    return someTableAdapter.getSomeData();
}

当我在这个函数中设置断点时,是否有可能检查返回值?go() 直接耦合到 .aspx 页面中的数据网格.

When I set a breakpoint in this function, is there a possibility to inspect the returned value? go() is directly coupled to a datagrid in an .aspx page.

检查返回的数据表的唯一方法是使用临时变量.不过,这有点不方便.没有别的办法吗?

The only way to inspect the returned datatable is to use a temporary variable. However, that's a bit inconvenient. Isn't there another way?

我不知道.请注意,如果您确实添加了一个变量,它无论如何都会在发布版本中被编译器删除...

Not that I know of. Note that if you do add a variable, it will get removed by the compiler in release builds anyway...

更新:此功能已添加到VS2013.您可以在自动窗口中查看返回值或在监视/立即窗口中使用 $ReturnValue.

Update: This functionality has been added to VS2013. You can see the return values in the autos windows or use $ReturnValue in the watch/immediate window.

该值只能在从函数返回后直接看到,因此访问它的最简单方法是在函数调用上放置断点并跳过 (F10) 调用.

The value can only be seen directly after returning from the function, thus the easiest way to access it is by putting a breakpoint on the function call and step over (F10) the call.

VS2015 更新:嘘!不幸的是,它似乎不在 VS2015 (devenv v14)
VS2017 更新:它回来了.(devenv v15)

Update for VS2015: boo! unfortunately, it doesn't appear to be in VS2015 (devenv v14)
Update for VS2017: it's back. (devenv v15)