关于验证码的输入问题

for (; ; )
{
string s = "qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM1234567890";
Random ran = new Random();
string biao = "";
for (int i = 1; i <= 4; i++)
{
biao += s.Substring(ran.Next(s.Length), 1);
}
Console.WriteLine(biao);
Console.Write("请输入验证码");
string shu = Console.ReadLine();
if (shu.ToLower() == biao.ToLower())
{
Console.WriteLine("输入正确");
break;
}
else
{ Console.Clear();
Console.WriteLine("输入错误!");
}
}

posted @ 2016-03-12 11:31  于超。  阅读(361)  评论(0编辑  收藏  举报