Customizing Breakpoint

Learn how to customize breakpoints for advanced debugging, including conditions, hit count adjustments in Visual Studio Code and Visual Studio 2022.

The breakpoint configurations can greatly enhance our debugging. These advanced techniques go beyond the basics, allowing us to fine-tune our debugging experience and gain deeper insights into our application’s behavior.

Steps to customize breakpoints

As we delve into the following steps, we’ll uncover the power of customizing breakpoints within our code. It is easy to make more complex breakpoints:

Step 1: If you are still debugging, click the “Stop” button in the debugging toolbar, navigate to the “Run” or “Debug | Stop Debugging” option, or press Shift + F5.

Step 2: Navigate to the “Run | Remove All Breakpoints” or “Debug | Delete All Breakpoints” options.

Step 3: Click on the WriteLine statement that outputs the answer.

Step 4: Set a breakpoint by pressing F9 or navigating to the “Run” or “Debug | Toggle Breakpoint” option.

Step 5: Right-click the breakpoint and choose the appropriate menu for your code editor:

  • In Visual Studio Code, choose the “Edit Breakpoint…” option.

  • In Visual Studio 2022, choose the “Conditions…” option.

Step 6: Type an expression, such as the answer variable must be greater than 99, and then press “Enter” to accept it, and note the expression must evaluate to true for the breakpoint to activate, as shown in the figure:

Get hands-on with 1400+ tech skills courses.