我想:ESC键
while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape))
{
// do something
}
这不能帮助我并没有做什么,我需要.. 我的代码是:
Console.WriteLine("Please enter your Login Details:");
Console.Write("User Name: ");
string userName = Console.ReadLine();
Console.Write("Password: ");
string Password = Console.ReadLine();
if (cmd.Login(userName, Password))
{
// my rest of my code
}
我需要在任何console.readline()
如果我按下ESC去第一个代码或开始把用户名和密码... 我需要按ESC在我的应用程序它重新启动到第一阶段在任何时间和任何阶段..这可能吗?
的[侦听在.NET控制台应用程序按键]可能的复制(http://stackoverflow.com/questions/5891538/listen-for-key-press-in-net-console-app) – KidCode
[检查这个问题!](http://stackoverflow.com/questions/5891538/listen-for-key-press-in-net-console-app) – KidCode
阅读整个问题!他不问如何暂停,直到按下一个键。他问他如何在“Read”或“ReadLine”中捕获按键,这样如果用户按下ESC,“Read”将中止,并且可以跳回到登录过程的开始。 –