What is the output, for loop - CSharp Language Basics

CSharp examples for Language Basics:for

Description

What is the output, for loop

Demo Code

class allinone//from ww w. j  av a2s.  c  o  m
{
   public static void Main()
   {
      int i;
      // One solution:
      for (i = 1; i <= 10; System.Console.WriteLine("{0}", i++))
         ;  // empty statement.
      // Another solution:
      for (i = 0; ++i <= 10; System.Console.WriteLine("{0}", i))
         ;  // empty statement.
   }
}

Result


Related Tutorials