Read console input with do while loop in CSharp

Description

The following code shows how to read console input with do while loop.

Example


/*from w w w.j  a  v a 2 s.  c  o  m*/
using System;
using System.IO;

public class MainClass {     
  public static void Main(string[] args)
  {
    string ans;
    do
    {
      Console.Write("Are you done? [yes] [no] : ");
      ans = Console.ReadLine();
    }while(ans != "yes");
  }
}

The code above generates the following result.





















Home »
  C# Tutorial »
    C# Language »




C# Hello World
C# Operators
C# Statements
C# Exception