Jump Statement in C#: Break, Continue, Goto, Return and Throw

A complete guide to jump statements in C#, covering break, continue, goto, return, and throw with practical examples of each.

What are Jump Statements?

Jump statements alter the normal sequential flow of a program, allowing execution to skip, exit, or transfer control to a different point in the code based on specific conditions.

break and continue

The break statement immediately exits the nearest enclosing loop or switch block, while continue skips the rest of the current iteration and moves directly to the next one, both giving you finer control over loop execution.

The goto Statement

The goto statement transfers control directly to a labeled statement elsewhere in the code. While powerful, it's used sparingly in modern C# since it can make code harder to follow if overused.

return and throw

The return statement exits a method and optionally sends a value back to the caller, while the throw statement raises an exception, immediately halting normal execution to signal that something has gone wrong.

Conclusion: Jump statements give you precise control over program flow beyond simple sequential execution. Used thoughtfully, they make your loops, methods, and error handling far more expressive and efficient.

Ready to Master C# Programming Course?

Join Uncodemy's hands-on training program with expert mentors and real-world projects.