do while loop c sharp code example

Example 1: while loop in c#

int i = 0;

while (i < 10)
{
    Console.WriteLine("Value of i: {0}", i);

    i++;
}

Example 2: c# do while loop

do {
   statement(s);
} while( condition );
_______________EX.___________________
int i = 0;

do
{
	Console.WriteLine(i);
	i++;
}
while (i < 5);

============OUTPUT======================
  0
  1
  2
  3
  4

Example 3: c# do while

do
{
	//Code here (will run at least once)
} while (true); //Condition to test for here

Example 4: c# do loop

int i = 0;

do
{
    Console.WriteLine("Value of i: {0}", i);
    
    i++;

} while (i < 10);

Tags:

Php Example