Can I find out the return value before returning w

2019-01-01 12:51发布

Take the following function:

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

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?

20条回答
若你有天会懂
2楼-- · 2019-01-01 13:08

The accepted answer doesn't work properly with Visual Studio 2015, but by placing a break point on the last line of the method and pressing F10, it will put all expressions of the return value into the locals window.

查看更多
还给你的自由
3楼-- · 2019-01-01 13:09

This can be done in Visual Studio 2013 with CLR 4.5.1 according to the customer feedback site. It was not available in previous versions for C#.

(Visual Studio 2008 and earlier supported it for VB.NET. It has always been available to C/C++ developers.)

查看更多
低头抚发
4楼-- · 2019-01-01 13:11

Old trick from the pre .NET days: Open the Registers window and look at the value of the EAX register. This contains the return value of the last function called.

查看更多
不再属于我。
5楼-- · 2019-01-01 13:12

Yes, there is a very nice way. One significant drawback is that you'd have to wait for 5, maybe 6 years. Since I see that you posted in November 2008, I suggest that you waaaaaa...

...aaaait. And voilà! Just for you, MS has released the latest Visual Studio 2013 where it's a default feature accessible from the menus while running in debug mode (menu DebugWindowsAutos).

查看更多
步步皆殇っ
6楼-- · 2019-01-01 13:17

I think you can determine this by looking at the RAX register in the Registers window (Debug / Windows / Registers). After stepping out (SHIFT + F11) of the function, check the RAX register. I don't know for a fact, but once upon a moon you could check a register (pre .NET days) and see the return value there. It might even be a combination of RAX and RBX, etc.

查看更多
人气声优
7楼-- · 2019-01-01 13:19

If you go to menu ToolsOptions, IntelliTrace, and change the setting to collect events and call information.

You can go back to the previous call event (Ctrl + Shift + F11) and see the temporary value returned from the method call in the autos window as a child of the method name.

This isn't showing you the return value for the method you are in. It just shows you the return value of the last method called in the current method.

So, it's fine for

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

as it shows you the return value for someTableAdapter.getSomeData().

But not for:

int go(){return 100 * 99;}
查看更多
登录 后发表回答