views:

380

answers:

4
+4  A: 

Unfortunately cluttering your code with temporary variables in the only way in managed code (C# or VB). The CLR has no support for "managed return values" in the debugger and hence VS does not either.

In C++ this feature is a bit simpler. C++ can just grab the register or stack location of the last return value. It doesn't have to deal with issues like a JITer and garbage collection. Both of which greatly complicate a feature such as this.

If you'd like this feature I strongly encourage you to file a feature request or vote for an existing one on connect

https://connect.microsoft.com/VisualStudio

JaredPar
A: 

You can set up your Main to return an int, if having a return value from Main() helps you, but yuou will not see the returned value of the test() routine, as Jared has mentioned. So, you do have to clutter up code if you want to see values.

Gregory A Beamer
+5  A: 

It is actually visible. Debug + Other Windows + Registers. Look at the value of EAX (RAX in x64). The value of simple integral types are returned in the EAX register. Long in EDX:EAX. Floating point in STx (XMM00 in x64).

Hans Passant
Nice! Thank you.
Cristi Diaconescu