
- #COMMAND LINE IN DEBUG CONSOLE APP VISUAL STUDIO CODE#
- #COMMAND LINE IN DEBUG CONSOLE APP VISUAL STUDIO WINDOWS#
These could be local variables, class members or static variables. The Autos window will show all variables used in the current line and in the previous line. It usually starts with this, which represents the current class.

The Locals will show local variables of the current scope. VS offers 2 automatic-watch tool windows: The Locals and Autos windows. For example, you can’t do a network request in this mode because there’s no way to guarantee it will have no side-effects. This works both in the Immediate Window and in the Watch Windows.Īs you might find out, not all expressions are supported in no-side-effects mode. You can add the, nse (No Side Effects) postfix to an expression, and it will evaluate without changing the application state. We can see here that m.number increased from 1 to 2. If I evaluate Foo() in the Immediate Window, number will increase and my application state will be changed: We saw before that evaluating the expression can cause side effects. Side Effects in Watch Window, QuickWatch, and Immediate Window To clear the window, right-click on it and select "Clear All".Like in command line interfaces, you can use the Up/Down arrow keys to paste previous expressions.

#COMMAND LINE IN DEBUG CONSOLE APP VISUAL STUDIO WINDOWS#
It’s kind of like the Watch window, but it acts more like a command line window in Windows or Linux.įor me, the immediate window was always more convenient than the Watch or QuickWatch windows. You can type in any expression and the immediate window will evaluate. The immediate window is available in the menu from Debug | Windows | Immediate or Ctrl + Alt + i. Search Depth is useful for nested fields and properties in classes. It searches through Name, Value, and Type and stops on first match. VS 2019 introduced a new feature: Search in the Watch windows, Locals, and Autos windows.Clicking on the refresh button will evaluate the expression, suffering the side effects.

Side effects are usually unwanted in a debugging session, so Visual Studio notifies you about it before evaluating.
#COMMAND LINE IN DEBUG CONSOLE APP VISUAL STUDIO CODE#
For example, in this code the IncreaseStatic() method will change a static variable. These can have side effects on the application state. You can evaluate methods and properties in the watch windows.When a value has changed since the last breakpoint, it’s shown in red.Maybe after you’ve edited it and fixed the problem. You can click the refresh button to try and re-evaluate the expression.When an expression can’t compile in the current scope and context, you will see a compiler error.There are some behaviors, rules and features to the watch window. That’s where you create a weak reference to any object, which can be evaluated from anywhere with $1, $2, and so on. You can use watch window evaluate the Object Id instance we talked about in Part 1. The most common scenario is with a breakpoint inside a loop. This happens if you hit the same breakpoint over and over again, or different breakpoints in the same class. While the DataTip and QuickWatch are more popular, the watch window is very useful when you need to re-evaluate the same variables and expressions multiple times. Right-click on a variable in the DataTip and choose "Add Watch".Right-click on a variable choose "Add Watch" in the context menu.Write them manually in a new row of the Watch window.To add items to watch do any of the following: So if you write an illegal expression, you’ll see the same compiler error. The same rules apply to expressions as to code. There are 4 watch windows in Visual Studio, which you can use in different contexts (Watch 1, Watch 2, etc.).Īny expression can be entered into the watch window. It’s available from Debug | Windows | Watch | Watch 1 or Ctrl + Alt + W + 1. It’s kind of like the DataTip you get when hovering over a variable, except that you can write any expression you want.

The Watch Window allows you to see value of variables and expressions while debugging.
