Move 'update' out of the for loop : For : Statement C# Examples


C# Examples » Statement » For »

 

Move 'update' out of the for loop









    
using  System;  
  
class  MainClass  {      
    public  static  void  Main()  {  
        int  i;  
  
        i  =  0;  //  move  initialization  out  of  loop  
        for(;  i  <  10;  )  {  
            Console.WriteLine("Pass  #"  +  i);  
            i++;  //  increment  loop  control  var  
        }  
  
    }      
}
    
   
  
   



Output

Pass #0
Pass #1
Pass #2
Pass #3
Pass #4
Pass #5
Pass #6
Pass #7
Pass #8
Pass #9


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Statement
» For