Give the syntax of using the while loop in a C# program?

The syntax of using the while loop in C# is:

while(condition) //condition

{

 //statements

}

You can find an example of using the while loop in C#: 

int i = 0;

while(i < 5)

{

 Console.WriteLine("{0} ", i);

 i++;

}

 

The output of the preceding code is: 0 1 2 3 4 .