Debug > Windows > Immediate
The Immediate window is used at design time to debug and evaluate expressions, execute statements, print variable values, etc. It allows you to enter expressions to be evaluated or executed by the development language during debugging.
You can use this window to issue individual Visual Studio commands. The available commands include EvaluateStatement, which can be used to assign values to variables. The Immediate window also supports IntelliSense.
To view variable values:
Steps:
1. Run in debug mode
2. Type variable name into immediate window, and press enter
or >Debug.Print msg
or ? msg
Note: ? is an alias for Debug.Print
To access properties of a variable, use the member access operator (.).
Eg:
msg.Length
11
You can perform calculations by entering expressions.
Eg:
msg.Length * 2
22
You can also execute methods, both against objects and static versions.
Eg:
msg.Replace("morning", "evening")
"Good evening world"
To clear immediate window:
Right-click within the white area > choose "Clear All"
Entering commands:
You must enter '>' when issuing Visual Studio commands in the Immediate window.
Task Solution Example
Evaluate an expression. Preface the expression with a question mark '?'. ? a+b
Temporarily enter Command mode Enter the command, prefacing it with '>' >alias
Switch to the Command window. Enter cmd into the window, >cmd
prefacing it with '>'
Switch back to the Enter immed into the window without '>' immed
immediate window
Note: keyboard shortcut: (Ctrl-Alt-I)
See: command window