Re: [問題] 誰能挑戰這程式?
※ 引述《multidecoy (站起來!激鋼人!!)》之銘言:
: 雖然我是學JAVA的,不過我也想知道...
用 Java(TM) 的恐怕就只能說抱歉了...
http://longhorn.msdn.microsoft.com
/lhsdk/ref/ns/system/c/console/m/readkey1.aspx
--
using System;
using System.Text;
class a
{
static void Main()
{
Console.Write("Input a password: ");
StringBuilder sb = new StringBuilder();
while (true)
{
ConsoleKeyInfo cki = Console.ReadKey(true);
if (cki.Key == ConsoleKey.Enter)
{
Console.WriteLine();
break;
}
if (cki.Key == ConsoleKey.BackSpace)
{
if (sb.Length > 0)
{
Console.Write("\b\0\b");
sb.Length--;
}
continue;
}
Console.Write('*');
sb.Append(cki.KeyChar);
}
Console.WriteLine("Your password is: {0}", sb.ToString());
}
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.94.64
推
推 210.85.196.13 01/10, , 1F
推 210.85.196.13 01/10, 1F
討論串 (同標題文章)
C_Sharp 近期熱門文章
PTT數位生活區 即時熱門文章