Visual Studio 2013 Displaying Return Value Of Method<!-- --> | <!-- -->Patrick Desjardins Blog
Patrick Desjardins Blog
Patrick Desjardins picture from a conference

Visual Studio 2013 Displaying Return Value Of Method

Posted on: September 26, 2013

Visual Studio 2013 has an awesome feature for those who like debugging. One limitation before Visual Studio 2013 was that we couldn't see the return value of a method, neither the return value of the method that call other method. Now, with Visual Studio 2013, it's possible to see the return value with the Debugging windows "Auto". It's also possible to see returning value by using the $ReturnValue keyword in the immediate windows.

Here is an example.

1class Program {
2 static void Main(string[] args) {
3 var x = Method1();
4 Console.WriteLine(x);
5 Console.ReadLine();
6 }
8 private static string Method1() { return "Method1 call " + Method2(); }
10 private static string Method2() { return "From Method2" + Method3(); }
12 private static string Method3() { return "From Method3"; }

If we set a breakpoint to the Method1 and we hit next, we will be at the ending curly bracket. Normally, we won't see the value of Method1 call " + Method2();

Now, we can see it.

ReturnValue 400x316

As you can see in the image above, we see in the corner left bottom the Auto Windows Panel. The first line is the value inside Method2() and the second line is the return value of Method1().