Conditional breakpoints in Visual Studio

There is a very useful feature in Visual Studio allowing you to set a conditional breakpoint on a line of code. The breakpoint will be triggered only when the condition is met.

To create a conditional breakpoint, just add a standard breakpoint, then move the mouse over it and click on the gear icon.

Adding a conditional breakpoint in Visual Studio

You can set one or more conditions by adding boolean expressions involving any variable in scope at the breakpoint line.

While setting a condition for a numeric variable is pretty straightforward, when you want to check a string variable you have to add some functions to be evaluated in the condition textbox:

Comparing strings in a conditional breakpoint

One thought on “Conditional breakpoints in Visual Studio

Leave a Reply