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 { static void Main(string[] args) { var x = Method1(); Console.WriteLine(x); Console.ReadLine(); }
3private static string Method1() { return "Method1 call " + Method2(); }
5private static string Method2() { return "From Method2" + Method3(); }
7private 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().