Is there an easy way to set conditional breakpoints in Visual Studio?
If I want to hit a breakpoint only when the value of a variable becomes something, how can I do
Set the breakpoint
as you do normally, right click the break point and select condion
option and sets your condition.
Set a breakpoint as usual. Right click it. Click Condition.
When you are using Express edition you can try this:
#if DEBUG
if( fooVariable == true )
System.Diagnostics.Debugger.Break();
#endif
if statement makes sure that in release build breakepoint will not be present.
Create a conditional function breakpoint:
In the Breakpoints window, click New to create a new breakpoint.
On the Function tab, type Reverse for Function. Type 1 for Line, type 1 for Character, and then set Language to Basic.
Click Condition and make sure that the Condition checkbox is selected. Type instr.length > 0
for Condition, make sure that the is true option is selected, and then click OK.
In the New Breakpoint dialog box, click OK.
On the Debug menu, click Start.
Visual Studio provides lots of options for conditional breakpoints:
To set any of these you
These options are as follows:
foo == 8
or some other expression.