How to: Use the QuickWatch Dialog Box
This topic applies to:
Visual Studio Edition |
Visual Basic |
C# |
C++ |
J# |
Express |
No |
No |
No |
No |
Standard |
No |
No |
No |
No |
Pro/Team |
Yes |
Yes |
Yes |
Yes |
As the name implies, QuickWatch provides a fast way to look at and evaluate variables and expressions. Because QuickWatch is a modal dialog box, you have to close it before you can continue debugging. (See How to: Watch an Expression in the Debugger.) You can also edit the value of a variable in QuickWatch. (See How to: Edit a Value in a Variable Window.)
Some users might, therefore, wonder why QuickWatch is useful. Why not simply add the variable or expression to the Watch window? Well, you could do that, but suppose you simply want to do a quick scratch calculation involving one or more variables? You don't want to clutter up the Watch window with such calculations. That's where QuickWatch comes in.
Another nice feature of the QuickWatch dialog box is the fact that it's resizable. If you want to look at the members of a large object, it's often easier to expand and look at the tree QuickWatch than it is in the Watch, Locals, or Autos window.
The QuickWatch dialog box does not allow you to view more than one variable or expression at a time. Also, because QuickWatch is a modal dialog box, you cannot perform operations such as stepping through your code while QuickWatch is open. If you need to do these things, use the Watch window instead.
Note |
---|
Some expressions have side effects that change the value of a variable or otherwise change the state of your program when they are executed. Evaluating an expression in the QuickWatch dialog box will have the same effect as executed the expression in your code. This can produce unexpected results if you do not pay attention to the side effects of the expression. |
Tip |
---|
In Visual Studio, you can get a quick look at a variable's value by placing the cursor over the variable. A small box called a DataTip will appear showing the value. |
Note |
---|
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings. |
To open the QuickWatch dialog box
- While in break mode, choose QuickWatch from the Debug menu.
To open the QuickWatch dialog box with a variable added
- While in break mode, right-click on a variable name in the source window name and choose QuickWatch from the shortcut menu. This automatically places the variable into the QuickWatch dialog box.
To add a QuickWatch expression to the Watch window
In the QuickWatch dialog box, click the the Add Watch button
Whatever expression was displayed in the QuickWatch dialog is immediately added to the list of expressions the Watch window.
If you are using a Visual Studio edition that supports multiple Watch windows, the expression is added to the Watch1 window.
See Also
Tasks
How to: Use Debugger Variable Windows