1.12. Jump Statements

Some of the loops and flow of control structures we have discussed will exit automatically when a condition is met (or not met), and some of them will not. The C# language defines a number of jump statements that are used to redirect program execution to another statement elsewhere in the code. The two types of jump statements that we will discuss in this section are the break and continue statements. Another jump statement, the return statement, is used to exit a method. We will defer our discussion of the return statement until Chapter 4.

You have already seen break statements in action earlier in this chapter, when they were used in conjunction with a switch statement. A break statement can also be used to abruptly terminate ...

Get Beginning C# 2008 Objects: From Concept to Code 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.