问题描述
- Visual Studio的输入小问题
-
vs中的控制台程序,如何让输入的东西显示为*号,不管怎都谢谢,看本问题的人,棒棒哒
解决方案
// Backspace Should Not Work
if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
{
pass += key.KeyChar;
Console.Write("*");
}
else
{
if (key.Key == ConsoleKey.Backspace && pass.Length > 0)
{
pass = pass.Substring(0, (pass.Length - 1));
Console.Write("b b");
}
}
参考:
http://stackoverflow.com/questions/3404421/password-masking-console-application
解决方案二:
好一顿抄啊,哈哈,其实就是Console.readKey
https://msdn.microsoft.com/en-us/library/471w8d85(v=vs.110).aspx
解决方案三:
oops,贴错了 Console.readKey(true)
https://msdn.microsoft.com/en-us/library/x3h8xffw(v=vs.110).aspx
时间: 2024-10-31 11:30:00