Mega Code Archive

 
Categories / C# / Development Class
 

Read a character from the keyboard

/* C#: The Complete Reference  by Herbert Schildt  Publisher: Osborne/McGraw-Hill (March 8, 2002) ISBN: 0072134852 */ // Read a character from the keyboard.    using System;    public class KbIn {      public static void Main() {      char ch;        Console.Write("Press a key followed by ENTER: ");        ch = (char) Console.Read(); // get a char           Console.WriteLine("Your key is: " + ch);    }    }