Do While Loop in C#

aaaaaaaaaaaaaaaaa

General form of Do While Loop


do
{
    this;
    and this;
    and this;
    and this;
}
while(this condition is true);

Do While Loop Printing 0 to 5 Integers

Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            int i = 0;
        do //first it printing 'i' value 0 and and after it adding 1
        {  //and checking condition if 'i'value not less then or
        Console.WriteLine(i); //equal to 5 then it processing again.
        //if U write Console.WriteLine("Pakistan Zindabad!");
             //then it printing 'Pakistan Zindabad!' 5 times.
            i++;  //U also write like 'i = i + 1;'.
        }
        while(i <= 5); //this is condition for checking.
        Console.ReadKey();
        }
    }
}
Output
Hello World!

Do While Loop Checking Name like a Password for Unlimited Chances

Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            String i; //in this program has no limit of chances
            do //when U entering wrong name then checking condition
            { //in while if 'i' value not equal to 'Bilal' then do again the
			Console.Write("Please Enter Password: ");
            i = Console.ReadLine(); //process, when U enter correct
            } //name 'Bilal' then stopping loop and printing 'OK Bilal!'.
            while(i != "Bilal");
            Console.WriteLine("OK Bilal!");
        Console.ReadKey();
        }
    }
}
Output
Hello
World!

Do While Loop Checking Name like a Password for 2 Chances
Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            String i;
            int j = 0; //when U enter name then assigning to 'i' and it
            do   //checking if 'i' value equal to 'Bilal' then it breaking and
            { //printing 'OK Bilal!', if 'i' not equal to 'Bilal' then printing
                Console.Write("Please Enter Password: ");
                i = Console.ReadLine(); //'Wrong Password!' and adding 1 to 'j'value
                if (i == "Bilal") //and checking condition and processing again.
                {
                    Console.WriteLine("OK Bilal!");
                    break; //'break' Breaking Statement.
                }  //it giving chance 3 times, if U not Enter 'Bilal' correct name
                else  //then it showing 'U are Lose'.
                {
                    Console.WriteLine("Wrong password!");
                }
                j++;
                }
            while (j <= 2);
            Console.ReadKey();
        }
    }
}
Output
Hello
World!