Counter-controlled repetition with the for iteration statement. - CSharp Language Basics

CSharp examples for Language Basics:for

Description

Counter-controlled repetition with the for iteration statement.

Demo Code

using System;//from   w ww. j a va  2  s. co m
class ForCounter
{
   static void Main()
   {
      // for statement header includes initialization,
      // loop-continuation condition and increment
      for (int counter = 1; counter <= 10; ++counter)
      {
         Console.Write($"{counter}  ");
      }
      Console.WriteLine();
   }
}

Result


Related Tutorials