Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 17-Dec-12 12:46pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 8,478
1 OriginalGriff 6,516
2 Peter Leow 3,587
3 Zoltán Zörgő 3,406
4 Richard MacCutchan 2,397


Advertise | Privacy | Mobile
Web02 | 2.8.150123.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100