Home » Softwares » Visual Studio » Visual Studio 2013 Displaying Return Value Of Method

Visual Studio 2013 Displaying Return Value Of Method

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.

class Program
{
	static void Main(string[] args)
	{
		var x = Method1();
		Console.WriteLine(x);
		Console.ReadLine();
	}


	private static string Method1()
	{
		return "Method1 call " + Method2();
	}

	private static string Method2()
	{
		return "From Method2" + Method3();
	}

	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

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().

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.