当某个键被按下时,如何使动作发生?是否可以使用Console.ReadKey();
The code does not work! this is just a schematic image so you can understand what I mean个
static void Play()
{
if (Console.ReadKey() == 'q')
{
Console.Beep(523, 500);
}
当某个键被按下时,如何使动作发生?是否可以使用Console.ReadKey();
The code does not work! this is just a schematic image so you can understand what I mean个
static void Play()
{
if (Console.ReadKey() == 'q')
{
Console.Beep(523, 500);
}
这将起作用,但当按下键时,ReadKey方法通常处于循环中,则使用If或Case语句来确定按下的键. 如果你想让应用程序监听按键并根据用户的按键分配代表,那就有点麻烦了. enter link description here个