CSharp examples for Language Basics:for
Counter-controlled repetition with the for iteration statement.
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(); } }