Home > Articles > Programming > Visual Studio

  • Print
  • + Share This
Like this article? We recommend

Like this article? We recommend

Using Watch Expressions

Watch expressions let you monitor the value of variables while you’re debugging the program. The simplest way to do this is to rest the mouse cursor on a variable name when the program is in break mode. Visual Studio will display a small window at the mouse cursor, showing the current value of that variable.

Other kinds of watches are set when the program is in break mode by selecting Debug > Windows > Watch and then selecting one of the four available watch windows. These windows all work in the same way, and Visual Studio provides four of them as a technique for you to organize your watches. Each watch window has three columns: Name, Value, and Type. You enter a variable name or any valid expression in the Name column, and Visual Studio displays the value of the variable or expression and its data type, as shown in Figure 4. As you continue to execute the program, the display updates to show changes to the data.

Figure 4

Figure 4 A watch window displays the value of variables and expressions.

  • + Share This
  • 🔖 Save To Your Account