Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static string ConsolePassword()
- {
- string Password = "";
- while (true)
- {
- var key = Console.ReadKey(true);
- if (key.Key == ConsoleKey.Enter)
- {
- Console.WriteLine();
- break;
- }
- else if (key.Key == ConsoleKey.Backspace)
- {
- if (string.IsNullOrEmpty(Password)) { continue; }
- Console.Write("\b \b");
- Password = Password[0..^1];
- }
- else
- {
- Console.Write("*");
- Password += key.KeyChar;
- }
- }
- return Password;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement