Console.ReadKey Method In C#
In this article, I will explain you about Console.ReadKey method in C#.
Console programs read input and write output. For reading purpose we can also use Console.ReadKey method. Console.ReadKey method is used to obtain the key pressed by the user in the console window. This method accept the character and also return character.
static void Main(string args)
// Write to console window.
s = Console.ReadKey();
if (s.Key == ConsoleKey.Insert)
Console.WriteLine("You pressed insert");
ConsoleKeyInfo is used to describes the console key that was pressed.
The output of following program