Friday, 17 August 2018

C#: do-while loop

do-while is a loop construct like while loop, but evaluates its expression at the end of the loop.

Syntax
do {
//statement(s)
} while (expression);

Program.cs
using System;

class Program
{
    static void Main(string[] args)
    {
        int var1 = 0;
        do
        {
            Console.WriteLine(var1);
            var1++;
        } while (var1 < 10);
    }
}

Output
0
1
2
3
4
5
6
7
8
9



Previous                                                 Next                                                 Home

No comments:

Post a Comment