The body of a loop can be empty : For : Statement C# Examples


C# Examples » Statement » For »

 

The body of a loop can be empty









    
using  System;  
  
class  MainClass  {      
    public  static  void  Main()  {  
        int  i;  
        int  sum  =  0;  
  
        //  sum  the  numbers  through  5    
        for(i  =  1;  i  <=  5;  sum  +=  i++)  ;  
  
        Console.WriteLine("Sum  is  "  +  sum);  
    }      
}
    
   
  
   



Output

Sum is 15


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» For