Using conditional expressions

Conditional expressions are often useful if you want to hit a breakpoint on some conditions. For example, you would like to debug a for statement when a specific index count is reached or when an item in a collection meets a specific value.

To add a conditional expression to a breakpoint inside Visual Studio 2017, select the Conditions checkbox from the Breakpoint Settings dialog and select the condition type as Conditional Expression from the dropdown. The next dropdown allows you to select the comparer (Is true or When changed). The text box next to it allows you to enter the condition. Here in this case, we entered i == 5:

In the preceding example, the breakpoint will directly hit when the variable i of the for loop sets to 5. You can then start your code debugging when the said conditions are met.

You can add multiple conditions by clicking the Add condition link which will be clubbed with the AND operator. Once a condition has been added to a breakpoint, the red breakpoint circle will show a + symbol.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.227.194