C# Console ReadLine

Description

Console ReadLine reads the next line of characters from the standard input stream.

Syntax

Console.ReadLine has the following syntax.


[HostProtectionAttribute(SecurityAction.LinkDemand, UI = true)]
public static string ReadLine()

Returns

Console.ReadLine method returns The next line of characters from the input stream, or null if no more lines are available.

Example


using System;//w  w  w  .  j  a  v a  2s  .  co m

public class Example
{
   public static void Main()
   {
      string line;
      Console.WriteLine("Enter one or more lines of text (press CTRL+Z to exit):");
      Console.WriteLine();
      do { 
         Console.Write("   ");
         line = Console.ReadLine();
         if (line != null) 
            Console.WriteLine("      " + line);
      } while (line != null);   
   }
}




















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version