Using break to exit a do-while loop : Break : Statement C# Examples


C# Examples » Statement » Break »

 

Using break to exit a do-while loop









    
using  System;  
  
class  MainClass  {    
    public  static  void  Main()  {    
        int  i;  
  
        i  =  -10;          
        do  {  
            if(i  >  0)  
                  break;  
            Console.Write(i  +  "  ");  
            i++;  
        }  while(i  <=  10);  
    
        Console.WriteLine("Done");    
    }    
}
    
   
  
   



Output

-10 -9 -8 -7 -6 -5 -4 -3 -2 -1 0 Done


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» Break