Use Conditional Breakpoints with Methods Return Value in Visual Studio 2015

By | May 19, 2015

Conditional Breakpoint in Visual Studio is a great way to optimize the debugging time and pause the execution only when the condition satisfied.  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.  You have seen this over here – Use Conditional Breakpoints with Method Calling in Visual Studio . This post cover the changes on breakpoint in new Visual Studio 2015

Let’s say you have a method with return type bool and you one of your breakpoint will only hit if IsValidData returns true.

private static bool IsValidData() => true;

If you are wondering about above code block, and how does that work. you must read this new features of C# 6.0 Expression – Bodied Methods in C# 6.0

Now, you have to set the conditional breakpoint from Breakpoint Settings as shown in below,


 Must Read : 10 Effective Debugging Tips for .NET Developer


Now, during the execution of code, when IsValidData() returns true ( in this case it is true), breakpoint will hit.


This will also works for other method returns type, but you need to check with a conditional operator in the breakpoint settings.