C# Do While Loop

In this article i am explaining about do while loop in C#. do while loop behavior same as while loop but only one differences between them is that, do while executes at least one time. The code executes first then check for specified loop condition. But in while loop, the specified loop condition evaluated first then executes the code.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Do_While_Example
    class Program
        static void Main(string[] args)
            int table, i, res;
            table = 12;
            i = 1;
                res = table * i;
                Console.WriteLine("{0} x {1} = {2}", table, i, res);
            // must put semi-colon(;) at the end of while condition in do...while loop.
            while (i <= 10);

Leave a Reply

Your email address will not be published. Required fields are marked *