Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Read a character from console in C#

Console.ReadKey() method accepts one character from console
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ForgetCode
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. ConsoleKeyInfo key = Console.ReadKey();
  15.  
  16. Console.WriteLine("\nYou entered "+key.KeyChar);
  17. }
  18. }
  19. }
  20.