szab.kel
szab.kel

Reputation: 2526

Evaluate expressions during debugging in Visual Studio

I am used to Jetbrains IDEA and Java, but now I have a project in .NET/C# and using Visual Studio 2017 (Community).

If I debug code in IDEA, I can always run code when the execution is stopped at a breakpoint using the 'Evaluate Expression' function of the IDE: https://www.jetbrains.com/help/idea/evaluating-expressions.html (Although it is for PyCharm, the Java one works the same: GIF).

Is there anything similar in Visual Studio?

Upvotes: 45

Views: 41817

Answers (4)

ganesan arunachalam
ganesan arunachalam

Reputation: 483

The Visual Studio debugger includes expression evaluators that work when you enter an expression in the QuickWatch dialog box, Watch window, or Immediate window. The expression evaluators are also work in the Breakpoints window and many other places in the debugger.

Here's documentation

Upvotes: 7

YanMax
YanMax

Reputation: 136

The closest I could find for the "Quick Evaluate Expression" from IntelliJ in Visual Studio is the "Quick Watch" tool.

You can either select your variable/expression and use the shortcut

  • Ctrl + D and then press Q

or use the context menu, right-click and hit "Quick Watch".

Upvotes: 3

Jaw
Jaw

Reputation: 61

Simply highlight the expression, right click and select "Evaluate in Debug Console" - it will give you the result in the DEBUG CONSOLE

Upvotes: 6

Luckybug
Luckybug

Reputation: 876

I have the exact same issue.

After researching I found the closest thing is Immediate Window which give you some intelligence while typing.

screenshot

Upvotes: 52

Related Questions