C#问题!Backspace键 消除上光标前的字符???
控制台应用程序staticvoidMain(string[]args){stringpassword=string.Empty;ConsoleKeyInfoinfo;do...
控制台应用程序
static void Main(string[] args)
{
string password = string.Empty;
ConsoleKeyInfo info;
do
{
info = Console.ReadKey(true);
if (info.Key != ConsoleKey.Enter && info.Key != ConsoleKey.Backspace && info.Key != ConsoleKey.Escape && info.Key != ConsoleKey.Tab && info.KeyChar != '\0')
{
password += info.KeyChar;
Console.Write('*');
}
} while (info.Key != ConsoleKey.Enter);
Console.WriteLine();
Console.WriteLine(password);
}
这段代码怎么样才能可以使用Backspace键 消除上一个字符啊 展开
static void Main(string[] args)
{
string password = string.Empty;
ConsoleKeyInfo info;
do
{
info = Console.ReadKey(true);
if (info.Key != ConsoleKey.Enter && info.Key != ConsoleKey.Backspace && info.Key != ConsoleKey.Escape && info.Key != ConsoleKey.Tab && info.KeyChar != '\0')
{
password += info.KeyChar;
Console.Write('*');
}
} while (info.Key != ConsoleKey.Enter);
Console.WriteLine();
Console.WriteLine(password);
}
这段代码怎么样才能可以使用Backspace键 消除上一个字符啊 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询