Hello Friends, In this tutorial, you are going to learn to do while loop in C#. We had already discussed for loop and while loop in C#. do while loop is very similar to while loop in C#.

After completing this tutorial you will be able to understand:

  • While loop in C#.
  • How to use do while loop in C#.
  • The difference between while and do while loop.


do while loop is similar to while loop except for the change that do while executes the specified code and then checks the condition. Another difference between while and do while loop is that do while loop executes for at least one time.

The syntax for declaring do while loop:

do while

The condition appears at the end of the loop it means the loop iterates for at least one time. If the condition returns true the program flow returns to do.

An example of do while loop:

Open Visual Studio and create a Console Application called dowhileDemo.

do while

Write following code in Program.cs file.

Run the application and look over the output window.

do while


Hope you understand this tutorial. I will appreciate your feedback, comments and suggestions.

View More:

Thank You.

1 Comment