while loop

while loop statement uses a bool value to control a loop body.

The while loop has the following form.


while(bool expression){
   loop body
}

using System;

class Program
{
    static void Main(string[] args)
    {
        int i = 5;

        while (i > 0)
        {
            Console.WriteLine(i);
            i--;
        }
    }
}

The output:


5
4
3
2
1
w_ww_.___j_a_v___a_2___s___.___co_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.