So let's use this code:
Console.ReadKey(true);
//Cancel the ReadKey prompt
Console.WriteLine("ReadKey was cancelled.");
Upon running the program, the only thing that should happen is that the output ReadKey was cancelled. should appear. How can I achieve this? Is it even possible?
Thanks in advance.
You can't cancel ReadKey, unless you abort the thread. (Force closing the program.)
I check if a key is available using the
Console.KeyAvailableproperty before calling ReadKey.