2015-10-24 41 views

回答

0

首先你的程序將在while循環中運行。閱讀輸入的單詞並檢查條件是否爲0。如果它是0,那麼通過打破循環來讓程序結束,否則使用繼續。如果您有任何困惑,請告訴我。

1

你不需要運行while循環來找出密鑰。 你必須與任何用戶輸入密鑰進行比較。

ConsoleKeyInfo info= Console.ReadKey(); 
     if (info.KeyChar == 48) 
      Environment.Exit(0); 
     else 
     { // do your things 
     } 
0

您可以使用while循環:

 ConsoleKeyInfo cki = new ConsoleKeyInfo(); 

     while (cki.Key != ConsoleKey.D0 && cki.Key != ConsoleKey.NumPad0) 
     { 
      cki = Console.ReadKey(true); 

      // your code here 
     } 
相關問題