using System;
class MainClass {
public static void Main (string[] args) {
Console.Write("password: ");
string password = null;
while (true){
var key = Console.ReadKey(true);
Console.Write("*");
password += key.KeyChar;
if (key.Key == ConsoleKey.Enter)
break;
}
}
}
while (true){
我试图让它读取输入的密钥,然后打印一个'*',但它只是无休止地打印*
var key = Console.ReadKey(true); Console.Write("*");