+ 1

So... I need to get an input from the user, just one char,

without him having to click enter, so readLine not good. I guess i need the ReadKey() method but don't know how to get the pressed key into a variable. string pressedButon = Console.ReadKey(); ----> give me an error can you help me please?

17th Nov 2019, 8:26 PM
Sharon Keren
Sharon Keren - avatar
5 odpowiedzi
+ 2
In the playground my vode does not work because it is a remote server. ReadKey Is just like Readline ReadLine causes the playground to ask for input. ReadKey does not work in the playground so it also does not ask for input. Please copy the code to your liocal IDE.
17th Nov 2019, 11:10 PM
sneeze
sneeze - avatar
17th Nov 2019, 10:25 PM
sneeze
sneeze - avatar
0
sneeze,your code says i pressed 0 but nothing is pressed..?
17th Nov 2019, 11:03 PM
Sharon Keren
Sharon Keren - avatar
0
use ConsoleKeyInfo key = Console.ReadKey(); Then you can convert it to Char: Char keyChar = Convert.ToChar(key);
18th Nov 2019, 8:31 AM
Filip Gajda
Filip Gajda - avatar
0
Ok, thanks
18th Nov 2019, 5:51 PM
Sharon Keren
Sharon Keren - avatar