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 } } }
Pass #0 Pass #1 Pass #2 Pass #3 Pass #4 Pass #5 Pass #6 Pass #7 Pass #8 Pass #9