A simple command line program that reads from the console using Console.Read() and Console.ReadLine()
/* C# Programming Tips & Techniques by Charles Wright, Kris Jamsa Publisher: Osborne/McGraw-Hill (December 28, 2001) ISBN: 0072193794 */ /* read.cs. A simple command line program that reads from the console using Console.Read() and Console.ReadLine(). Compile this program using the following line: C:>csc read.cs */ using System; public class ReadCmdLine { static void Main() { Console.WriteLine ("First, using the Read() function " + "without clearing the buffer"); int arg; Console.Write("Type one or more characters: "); while ((arg = Console.Read()) > 10) { if (arg == 13) Console.WriteLine (" <EOL>"); else Console.Write (Convert.ToChar(arg)); } Console.WriteLine(); Console.WriteLine ("Now, using the Read() function and " + "clearing the buffer"); Console.Write("Type one or more characters: "); arg = Console.Read (); string str = Console.ReadLine(); Console.WriteLine ("The character is " + Convert.ToChar(arg)); } }