using while statements C# code example
Example 1: c sharp exit while loop
// To forcibly exit a while loop use 'break'
while (true)
{
// Do something
if (conditional)
{
break;
}
}
Example 2: while loop in c#
int i = 0;
while (i < 10)
{
Console.WriteLine("Value of i: {0}", i);
i++;
}