Do While Loop

C#C# do while loop is pretty much like a while loop.  The only difference is, your code inside the loop will be executed at least once regardless to your loop condition, which will be checked after the execution of your code inside the loop.  The C# sample code is given below and it is pretty much easy to understand how it works if you have been following the previous C# tutorials accordingly.

using System;

namespace MyHelloWorld
{   
    class Program
    {
        static void Main(string[] args)
        {
            int number = 0;

            do
            {
                Console.WriteLine(number);
                number++;
            } while (number == 10);            
        }
    }
}

 Output:

0
Press any key to continue . . .