In C#, the break; statement allows us to break a loop or a block of statements where it is enclosed. For example, in a recursive function, you might need to break after n number of iterations. Alternatively, in an example where you want to print the first 5 numbers in a loop of 10 iterations, you will want to use the break statement:
for (int i = 1; i <= 10; i++)
{
if (i == 5)
{
break;
}
Console.WriteLine(i);
}
//output:
1
2
3
4