how to do a while loop in c# code example
Example 1: c# while loop
int n = 0;
while (n < 5)
{
Console.WriteLine(n);
n++;
}
Example 2: c# do while
do
{
//Code here (will run at least once)
} while (true); //Condition to test for here
int n = 0;
while (n < 5)
{
Console.WriteLine(n);
n++;
}
do
{
//Code here (will run at least once)
} while (true); //Condition to test for here