private string GetPassword()
{
List<char> pwd = new List<char>();
while (true)
{
ConsoleKeyInfo i = Console.ReadKey(true);
if (i.Key == ConsoleKey.Enter)
{
break;
}
else if (i.Key == ConsoleKey.Backspace)
{
if (pwd.Count > 0)
{
pwd.RemoveAt(pwd.Count - 1);
Console.Write("\b \b");
}
}
else
{
pwd.Add(i.KeyChar);
Console.Write("*");
}
}
return new string(pwd.ToArray());
}