Do while loop : Do While : Statement C# Examples


C# Examples » Statement » Do While »

 

Do while loop





A do-while loop will always execute at least once.
The general form of the do-while loop is




    
do  {
statements;
}  while(condition);
    
   
  
   





    
using  System;

class  MainClass
{
        public  static  void  Main()
        {
                int  n  =  0;
                do
                {
                        Console.WriteLine("Number  is  {0}",  n);
                        n++;
                }  while  (n  <  10);
        }
}
    
   
  
   



Output

Number is 0
Number is 1
Number is 2
Number is 3
Number is 4
Number is 5
Number is 6
Number is 7
Number is 8
Number is 9


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Do While