Break will exit from the loop.
Break will exit from the loop without waiting until given condition for the loop is false.
Within the looping control statements you can use the statements break and continue.
Example program for Break in C#
using System;
//Program to print numbers 1 to 10
namespace ProgramCall
{
class BreakExample
{
static void Main()
{
int num = 0;
while (true)
{
//Increment the number
num++;
Console.WriteLine(num);
//if num is 10 , break the loop
if (num == 10)
break;
}
Console.ReadLine();
}
}
}
Output
1
2
3
4
5
6
7
8
9
10