There may be few situations where you need to debug and inspect values of all variables in a multi-line statement. In VS 2013 and 2015, we can easily inspect variables and method return values involved in a multi-line statement like
int d = a + b + c + addRandomNbr();
Let's create a sample C# console application in VS 2015 and add the below piece of multi-line code:
- static void Main(string[] args)
- {
- int a = 0, b=10, c=20;
- int d = a + b + c + addRandomNbr();
- Console.WriteLine(d);
- Console.ReadKey();
- }
- static int addRandomNbr()
- {
- return new Random().Next();
- }
Let's keep the breakpoint on line 04 and hit F10, We can see values of all variables in Autos window:
Let's press F10, Now we can inspect values of all variables and return value of method addRandomNbr() as well.
By using Autos window, we can easily debug and inspect multi-line statements.