Reading Console Input : Console Read « Development « C# / CSharp Tutorial






  1. Console.In is an instance of TextReader.
  2. Console.In defines two input methods: Read() and ReadLine().

To read a single character, use the Read() method:

static int Read()

To read a string of characters, use the ReadLine() method:

static string ReadLine()
  1. ReadLine() reads characters until you press ENTER
  2. ReadLine() returns these characters in a string object.
  3. ReadLine() will throw an IOException on failure.








14.6.Console Read
14.6.1.Reading Console Input
14.6.2.Read a character from the keyboard.
14.6.3.Input from the console using ReadLine().
14.6.4.Read a string from the keyboard, using Console.In directly
14.6.5.Read input from console
14.6.6.Read user selection from keyboard
14.6.7.How to read a character entered using the keyboard
14.6.8.How to read a string entered using the keyboard