Mega Code Archive

 
Categories / C# Tutorial / Development
 

Reading Console Input

Console.In is an instance of TextReader. 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() ReadLine() reads characters until you press ENTER ReadLine() returns these characters in a string object. ReadLine() will throw an IOException on failure.