Using ReadLine to Read Characters - CSharp Language Basics

CSharp examples for Language Basics:Console

Description

Using ReadLine to Read Characters

Demo Code

using System;/*from  w ww .  j  a v  a 2  s. c om*/
using System.Text;
class ReadLine
{
   public static void Main()
   {
      StringBuilder Input = new StringBuilder();
      string buff;
      Console.WriteLine("Enter text. When done, press Ctrl+Z:");
      while ( (buff = Console.ReadLine()) != null )
      {
         Input.Append(buff);
         Input.Append("\n");
      }
      Console.Write( Input );
   }
}

Result


Related Tutorials