Change your code something like this:
Console.Write("Enter Password :");
ConsoleKeyInfo key; String pwd = "";
do
{
key = Console.ReadKey(true);
if (key.Key != ConsoleKey.Backspace && key.Key!=ConsoleKey.Enter)
{
pwd += key.KeyChar;
Console.Write("*");
}
} while (key.Key != ConsoleKey.Enter);
Console.ReadLine();
Console.WriteLine(pwd);
Console.ReadKey();
OR
If you want to use while loop assign the value of key like this:
ConsoleKeyInfo key='\0';
Good Luck
Enjoy!