Use int value to control a while loop in CSharp

Description

The following code shows how to use int value to control a while loop.

Example


using System;/*from  w w  w .  j av a  2 s . c o m*/

public class MainClass {
    public static void Main(string[] args)    {
        int i = 5;
        while (i > 0){
            Console.WriteLine(i);
            i--;
        }
    }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




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