次の方法で共有


Understanding the Autos Window

Keyboard:  CTRL + ALT + V, A
Menu:  Debug -> Windows -> Autos
Command:  Debug.Autos
Versions:  2008,2010
Published:  10/7/2010
Code:  vstipTool0103

 

So you've always wondered what the Autos window does.  It does look a whole lot like the Locals window doesn't it?  Well let's take a closer look.  According to the only public documentation I could find on MSDN (https://msdn.microsoft.com/en-us/library/aa290702(VS.71).aspx) here is what it does:

===

The Autos window displays variables used in the current statement and the previous statement. (For Visual Basic, it displays variables in the current statement and three statements on either side of the current statement.)

The current statement is the statement at the current execution location (the statement that will be executed next if execution continues). The debugger identifies these variables for you automatically, hence the window name.

===

 

 

 

Changing Values

Just like the Locals window, you can change values in the Autos window:

image  

 

 

 

Current and Previous Statement

 

Simple Example

Okay let's break this down.  The Autos window, in both C# and VB, does, in fact, show variables used in the current statement and previous statement.  Here is a simple example with some variables:

image

 

As you can see, it is just showing the variable on the current line and the one before it-nothing else.  Even though there are several lines with variables around it, the Autos window is NOT concerned with those variables.  Now compare this to the Locals window that shows every variable in scope:

image

 

 

Another Example

I thought it would be instructive to see, step-by-step, how this works.  Here I have stopped at in some code:

image

 

Notice it shows the current variable and the object variable which exists all the time.  Now if I go down two lines:

image

 

All we are left with is the object variable.  If I go down another three lines:

image

 

Now we can see the "eLocal" is about to be used and if we go one more line:

image

 

We can finally see that "eLocal" has changed and "d" has shown up again since it is being used on the current line.

 

 

 

VB Shows Three Statements on Either Side

This is no longer true.  The VB Autos window acts just like the C# Autos window and only shows the current line and one prior:

image

Comments

  • Anonymous
    July 01, 2014
    Very helpful with picture illustration. Thank you