Conditional breakpoints in Visual Studio

There is a very useful feature in Visual Studio allowing you to add a conditional breakpoint to 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 hover 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 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



Leave a Reply