How it works...

The condition is evaluated on every loop. When the condition is true, the breakpoint will be hit. In the example illustrated in this recipe, the true benefit of a conditional breakpoint is somewhat lost because it is a very small list. Consider this though. You are binding a data grid. Items on the grid are given specific icons based on the status of the item. Your grid contains hundreds of items, because this is a hierarchical grid. You identify the primary ID of the item which is bound to the grid. This primary ID is then passed to other code logic to determine the status, which determines the icon displayed.

To debug and pressing F10 through hundreds of loops is not productive in any event. With conditional breakpoints, ...

Get C# 7 and .NET Core Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.