CSharp - do while loops

Introduction

do-while loops test the expression after the statement block has executed.

The loop body block in do while loop is always executed at least once.

int i = 0;
do
{
       Console.WriteLine (i);
       i++;
}
while (i < 3);

Demo

using System;
class MainClass//from w  ww  .  j a v a2s  . co m
{
   public static void Main(string[] args)
   {
         int i = 0;
         do
         {
           Console.WriteLine (i);
           i++;
         }
         while (i < 3);

   }
}

Result