Watching the Value of a Variable or Expression

A watch enables you to track the changes in the value of a variable or expression during program execution. You can set a watch directly from the Source Editor or by using the Add Watch dialog box.

To set a watch using the Source Editor:

  1. Select the variable or expression in the Source Editor, right-click, and choose Add Watch.

    The Add Watch dialog box opens with the variable or expression entered in the text field.

  2. Click Ok.

To set a watch using the Add Watch dialog box:

  1. From the main window, choose Debug and choose Add Watch (Ctrl-Shift-F7).
  2. In the Add Watch dialog box, type the variable or expression you want to monitor.
  3. Click OK.

Watches are displayed in the Watches view of the Debugger window. A watch is evaluated when program execution stops and the watch is in the scope of the current method on the call stack. Clicking the turner control to the left of a watch object expands the object to show its contents.

See also
Creating a Fixed Watch
Viewing Variables in the Current Context

Legal Notices