Use commas statement in a for loop in CSharp

Description

The following code shows how to use commas statement in a for loop.

Example


using System; /*w  ww.j  a  va2s .  c  o m*/
 
public class MainClass {    
  public static void Main() {    
    int i, j; 
 
    for(i=0, j=10; i < j; i++, j--) 
      Console.WriteLine("i and j: " + i + " " + j); 
  } 
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception