Skip to content

C# Basics

  • break: terminates the current loop/switch.
  • continue: skips the current iteration and continues.

Supported in for/foreach/while/do-while and switch.

Example:

for (int i = 0; i < 10; i++)
{
if (i == 5) continue; // skip 5
if (i == 8) break; // stop at 8
}