During debugging in Visual Studio most of the time we used Watch Window for inspect code. However we overlooked two additional debugging tools “Autos” and “Locals” Window. These windows are tremendous helpful in some cases where you want to monitor your scope object during debugging. In this post, lets have a look what is the use of Autos and Locals windows and how they are differ.
Locals windows automatically displays the list of variables and it’s values within the scope of current methods. If your debugger currently hits a particular breakpoint and if you open the “Locals” window, it will show you the current scope object variable along with the value.
Consider you have following code block running and you turned on the Locals Windows ( Debug –> Windows –> Locals), you should have able to see the following listed active objects with the values.
Keep in mind it will display the list of objects with values which are live within the current scope. To understand it better, put a breakpoint inside the for loop and verify the Locals window once again,.
At this point, as “I” is an active object, that appear in the Locals Windows.
To summarize, the locals window shows everything which are currently in scope.
These variables are also automatically detect by the Visual Studio debugger during the debugging. Visual Studio determines which objects or variables are important for the current code statement and based on that, it lists down the “Autos” variable. Generally this shows the object in current statement and the previous statement with in that current scope.
Must Read / Related with Autos : Function return values inspection in Visual Studio
So if we open the Autos windows for previous code block execution, you will only see “I” and “temp” with in that. Because, “I” is currently which is getting executed and “temp” was the previous statement.
All in all, the autos window is a subset of the locals window. When the local windows shows all the variable with in current scope, the Autos shows only the current and previously executed object’s value.
Hope this helps !