Back to course

Break and Continue Statements

C# Zero to Hero: Comprehensive Programming Masterclass

Controlling Loops

Sometimes you need to exit a loop early or skip an iteration.

Break

Jumps out of the loop completely. csharp for (int i = 0; i < 10; i++) { if (i == 4) break; Console.WriteLine(i); }

Continue

Skips the current iteration and moves to the next one. csharp for (int i = 0; i < 10; i++) { if (i == 4) continue; Console.WriteLine(i); }