42.1. Breakpoints

A breakpoint is used to pause, or break, an application at a particular point of execution. An application that has been paused is said to be in Break mode, causing a number of the Visual Studio 2008 windows to become active. For example, the watch window can be used to view variable values. Figure 42-1 shows a breakpoint that has been added to the constructor of the Customer class. The application will break on this line if the Customer class constructor is called.

Figure 42.1. Figure 42-1

42.1.1. Setting a Breakpoint

Breakpoints can be set either through the Debug menu, using the Breakpoint item from the right-click context menu, or by using the keyboard shortcut, F9. The Visual Studio 2008 code editor also provides a shortcut for setting a breakpoint using a single mouse click.

An application can only be paused on a line of executing code. This means that a breakpoint set on either a comment or a variable declaration will be repositioned to the next line of executable code when the application is run.

42.1.1.1. Simple Breakpoints

A breakpoint can be set on a line of code by placing the cursor on that line and enabling a breakpoint using any of the following:

  • Selecting Toggle Breakpoint from the Debug menu

  • Selecting Insert Breakpoint from the Breakpoint item on the right-click context menu

  • Pressing F9

  • Clicking once in the margin of the code window with the ...

Get Professional Visual Studio® 2008 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.