CSharp examples for Language Basics:for
A for loop contains three clauses as follows:
for (initialization-clause; condition-clause; iteration-clause)
statement-or-statement-block
Initialization clause - Executed before the loop begins; used to initialize one or more iteration variables
Condition clause - The bool expression that, while true, will execute the body
Iteration clause - Executed after each iteration of the statement block; used typically to update the iteration variable
For example, the following prints the numbers 0 through 2:
using System;/*w w w .j a va 2 s . c o m*/ class Test { static void Main(){ for (int i = 0; i < 3; i++) Console.WriteLine (i); } }