Simplest While loop : While : Statement C# Examples


C# Examples » Statement » While »

 

Simplest While loop





The general form of the while loop is




    
while(condition)  statement;
    
   
  
   





    
using  System;

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



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
» While