using System;
namespace login.system
{
class code
{
static void system(string[] args)
{
Console.Write("Enter a username:");
string username = Console.ReadLine();
Console.Write("Enter your first name:");
string name = Console.ReadLine();
Console.Write("password: ");
string password = null;
bool flag = true;
while (flag)
{
var key = Console.ReadKey(true);
while (key.Key != ConsoleKey.Enter)
{
while (key.Key != ConsoleKey.Backspace)
{
password += key.KeyChar;
Console.Write("*");
}
// This bit here is meant to write a backspace character
// from the console, removing an * if backspace is
// entered... but it's not.
if (key.Key == ConsoleKey.Backspace)
{
Console.Write("\b");
}
if (key.Key == ConsoleKey.Enter)
{
flag = false;
}
}
}
}
}
当用户输入并回车以继续时,还会打印一个*,我该如何解决