Click here to Skip to main content
12,453,873 members (84,072 online)
Rate this:
 
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 11:46am
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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160826.1 | Last Updated 17 Dec 2012
Copyright © CodeProject, 1999-2016
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