Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I find out the return value before returning while debugging in Visual Studio?

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?

like image 965
doekman Avatar asked Nov 06 '08 09:11

doekman


People also ask

How do I check the return value in Visual Studio?

View return values for functions If the window is closed, use Debug > Windows > Autos to open the Autos window. In addition, you can enter functions in the Immediate window to view return values. (Open it using Debug > Windows > Immediate.)

How do I go back to previous line while debugging in Visual Studio?

So, if you've just taken a step in live debugging (F10 or F11), you can use the Step Backward button to quickly navigate to the previous step. This will automatically put Visual Studio in Historical debugging mode, at the line of code you've stepped back to.

How can I see the variable value while debugging in Visual Studio?

Hover over a variable to see its value. When stopped in the debugger hover the mouse cursor over the variable you want to look at. The DataTip will appear showing you the value of that variable. If the variable is an object, you can expand the object by clicking on the arrow to see the elements of that object.

Can you step back in Visual Studio?

The recent updates of Visual Studio 2017 (version 15.5 Preview) comprise with several sets of new features and improvements. Once of such great enhancement is “step-back” while debugging. Now, you can perform a step-backward and forward while debugging your code with IntelliTrace Debugging.


1 Answers

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

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.

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.


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

like image 101
Marc Gravell Avatar answered Oct 27 '22 20:10

Marc Gravell