Toggle Breakpoints

Now we look at how you can set breakpoints and use the execution change commands as you step through your code.

l. In the Code Editor, select the second line of code.

2. On the Debug menu, click Toggle Breakpoint. This sets a breakpoint in the line of code that we know causes an error.

3. Press F5 to run the solution code. The application halts at the line of code that contains the breakpoint before that line is executed. If you were to right-click the next line and click Run To Cursor, the debugger would encounter the exception and display the Exception Assistant.

4. Right-click the line of code beneath the breakpoint, and click Set Next Statement in the shortcut menu.

The debugger moves to the next line of code without executing the line that causes the exception. This feature enables you to continue stepping through your code without having to rebuild and rerun the application. At this point, you can stop debugging and close the application.

0 0

Post a comment