Viewing Variables

The Visual Studio 2005 debugger allows you to view and modify the contents of certain variables at run time. After the debugger pauses the extension at a breakpoint, you can view the contents of a variable in any of the following ways:

  • Select the variable in the code window and place the cursor over the variable. Visual Studio 2005 will usually display the contents of the variable in a ToolTip.
  • Select the variable in the code window, right-click the variable, and select Quick Watch. Visual Studio 2005 will usually display the contents of the variable in the QuickWatch window.
  • Select the variable in the code window, select Debug, and then select Quick Watch. Visual Studio 2005 will usually display the contents of the variable in the QuickWatch window.
  • Select the variable in the code window, right-click the variable, and select Add Watch. If possible, Visual Studio 2005 will display the contents of the variable in one of the Watch windows. The individual Watch windows can be displayed or hidden by selecting Debug, then Windows, then Watch, and then the desired Watch window.

When the debugger pauses the extension at a breakpoint, you can modify the contents of a variable while the code is running by viewing the variable in either the QuickWatch or Watch windows, and then selecting the Value of the variable. You can then enter the desired value for the variable using the keyboard and mouse.

Caution  Extreme caution must be exercised when changing variable values because it is very easy to enter an invalid value for the variable, which can cause the code to throw an exception and possibly become unstable.

For more information about the debugger and its features, see the Visual Studio 2005 documentation.

Send comments about this topic to Microsoft

Build date: 2/16/2009