exit do while loop 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: c# do while
do
{
//Code here (will run at least once)
} while (true); //Condition to test for here
Example 3: c# do loop
int i = 0;
do
{
Console.WriteLine("Value of i: {0}", i);
i++;
} while (i < 10);