The while loop
The while keyword is used to create while loop in C#. The syntax for while loop is:

The Code:

The Output of Your Program:

Notes:
C# while loop consists of a test-expresion. If the test-expresion is evaluated to true, statements inside the while loop are executed. After execution, the test-expresion is evaluated again. If the test-expression is evaluated to false, the while loop terminates.
The do…while Loop
The do and while keyword is used to create a do…while loop. It is similar to a while loop, however there is a major difference between them.
In while loop, the condition is checked before the body is executed. It is the exact opposite in do…while loop, i.e. condition is checked after the body is executed.
This is why, the body of do…while loop will execute at least once irrespective to the test-expression.

The Code:

The Output of Your Program:

