-
static void CancelDemo() { int i = 0; //Console.WriteLine("Press ESC to stop"); //while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) //{ // Console.WriteLine(++i); //} Console.WriteLine("Enput any key to stop console output!"); while(!Console.KeyAvailable) { Console.WriteLine(++i); } }
static void CancelDemo() { int i = 0; Console.WriteLine("Press ESC to stop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) { Console.WriteLine(++i); } }
C# while loop Running until user press key
猜你喜欢
转载自www.cnblogs.com/Fred1987/p/12100627.html
今日推荐
周排行