Visual Studio Breakpoints allow you to put conditional breakpoint. If and only if that condition is satisfied, the debugger will pause the execution. Along with the normal condition with in conditional breakpoint in visual studio, we can call a methods from the condition field and based on the return value debugger will stop at the breakpoint.
Let’s say you have a method with return type bool and you one of your breakpoint will only hit if IsValidData returns false.
private bool IsValidData() { bool retsult = true; // Do Some operation // result value may change based on the operation return result; }
Now, you have to set the conditional breakpoint as shown in below,
Now, if the result=true
the breakpoint will never hit, breakpoint will only hit if IsValidData = false
.
Similarly not only for Boolean type, you can use the same for any type of return value. As shown in below image, we can set conditional breakpoint based on some string value as well.
You, may think typing condition inside condition text box will be a difficult task, but don’t worry, you can use intellisense with in conditional textbox as well.
Pingback: 14 Useful .NET Debugging Tips & Tricks in Visual Studio « Abhijit's World of .NET
Pingback: SHRAVAN Weblog » 14 Useful .NET Debugging Tips & Tricks in Visual Studio