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   www .j a  va2  s. c  o  m
{
   public static void Main(string[] args)
   {
         int i = 0;
         do
         {
           Console.WriteLine (i);
           i++;
         }
         while (i < 3);

   }
}

Result