Jump Statements: break, continue, goto, return

Jump statements are used to do just that—jump from one statement to another.

break

The break statement breaks out of the current iteration or switch statement and continues execution after that statement.

continue

The continue statement skips all the later lines in the current iteration statement and then continues executing the iteration statement.

goto

The goto statement can jump directly to a label. Because using goto statements is widely considered to be harmful, C# prohibits some of their worst abuses. A goto can’t be used to jump into a statement block, for example. The only place where their use is recommended is in switch statements or to transfer control to outside a nested loop (though they can be used elsewhere).

return

The return statement returns to the calling function and optionally returns a value as well.

Source: Gunnerson Eric, Wienholt Nick (2005), A Programmer’s Introduction to C# 2.0, Apress; 3rd edition.

Leave a Reply

Your email address will not be published. Required fields are marked *