C# Jump Statements

tutorial and example
tutorial and example

Break is a jump statement which is used to break the current loop or current flow of program and transfer the program control to the next block. It is used inside the for loop and switch statements. If you are using nested loop into your program then break statement will break only inner loop. You can’t use break outside any loop or switch statements .

Let’s see a simple example of break statement:

Output

C# Continue statement:

Continue statement is used to skip the remaining code of the loop for a specified condition and continue the flow control from next iteration. It is used if you don’t want to run a certain part of loop for a separate condition.

Let’s see a simple example of continue statement

Output

C# goto statement:

Goto statement is also known as a jump statement. It transfers the flow of control somewhere else in the program (where the label is mentioned). It is mainly used to break deeply nested loop or nested switch statements. Using goto statements is mainly avoided since it increases program complexity.

C# goto statements Example:

Output