Click here to Skip to main content
16,015,559 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hey guys,

i'm currently writing a little console game at the moment and i have come across something. i need a little password thing where you can't see the characters. lets say i were to put in a 'Console.Write("password: ")' and then 'string password = Console.ReadLine()' it would just do that, but i need it so that it hides the characters that you are typing in or it changes them into something like '*'. is it possible to do that? can someone please provide me with some code and a little explanation? thanks!
Posted

Use Console.ReadKey to get a key. Use Char.IsControl to work out if it's a control key ( like backspace ). Emit a *
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900