替换Console.ReadLine中的字符() [英] Replace Characters in Console.ReadLine()

查看:105
本文介绍了替换Console.ReadLine中的字符()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,



我现在正在写一个小游戏机游戏,我遇到了一些东西。我需要一个小密码的东西,你看不到人物。让我说我要输入一个''Console.Write(密码:)''然后''字符串密码= Console.ReadLine()''它会这样做,但我需要它,以便它隐藏您正在输入的字符或将其更改为*的字符。有可能这样做吗?有人可以请我提供一些代码和一些解释吗?谢谢!

解决方案

请看看:

http://www.dotfusion.net/tag/c-console-password-masking [ ^ ]

http://ryepup.unwashedmeme.com/blog/2007/07/05/reading-passwords-from-the-console- in-c / [ ^ ]


使用Console.ReadKey获取密钥。如果它是一个控制键(如退格键),请使用Char.IsControl计算出来。发出*


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!

解决方案

Please have a look:
http://www.dotfusion.net/tag/c-console-password-masking[^]
http://ryepup.unwashedmeme.com/blog/2007/07/05/reading-passwords-from-the-console-in-c/[^]


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


这篇关于替换Console.ReadLine中的字符()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆