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
Create a breakpoint as you normally would, right click the red dot and select "condition".
If you came from Google, this answer might be what you are searching for.
Click Debug> New BreakPoint > Function Breakpoint
there choose the conditional Breakpoint.
Just another way of doing it, (or if you are using express) add the condition in code:
if(yourCondition)
{
System.Diagnostics.Debugger.Break();
}
The breakpoint will only get hit when i is 5.
Writing the actual condition can be the tricky part, so I tend to
Advantages of using the Immediate window:
This example breaks when the code is referring to a table with the name "Setting":
table.GetTableName().Contains("Setting")