Viewing Local Variables and Parameters in the Debugger

The Local Variables window enables you to monitor or detect changes to local variables and parameters used in your methods.

To display the Local Variables window if it is not already displayed

The Local Variables window automatically monitors all parameters and local variables in your methods. Use the Watches window to reduce the number of variables that are monitored.

The Local Variables window, shown in the following image, displays the values of all local variables in your methods. As your code executes, the values of the items change and the Local Variables window is updated.

For each local variable or parameter, the name. value, usage, and type of the item are displayed.

Local variable values are highlighted when they change.

By default, the variables and parameters in the Local Variables window are displayed in the order in which they appear in the method. You can sort the table of displayed variables by clicking on the fixed column cell of the table. Clicking in the fixed part or a column causes the entries to be displayed alphabetically sorted (case‑insensitive) by that column for the rest of the debugger session. For example, clicking on an identifier in the Name column sorts the list by identifier name. Clicking the sorted fixed column cell again inverts the sorted list.

If the table is sorted, a numeric sorting indicator is displayed in the fixed cell of the column. If the column selected for sorting is not the identifier column, the identifier column is the second sort key.

You can inspect or modify variables selected in the Local Variables window. For details, see "Inspecting and Modifying Values", later in this chapter.