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?
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.)
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.
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.
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.
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With