在 Visual Studio 中调试时,我可以在返回之前找出返回值吗? [英] Can I find out the return value before returning while debugging in Visual Studio?

查看:28
本文介绍了在 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)

这篇关于在 Visual Studio 中调试时,我可以在返回之前找出返回值吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆