C# 随机四位数验证码

string str ="abcdefghigklmnopqrstuvwxyzABCDEFJHIGKLMNOPQRSTUVWXYZ1234567890";
while(true){
string yzm = ""; Random rm = new Random(); for (int i = 0; i < 4; i++) { int index = rm.Next(0, str.Length); string x = str.Substring(index, 1); yzm += x; } Console.Write(yzm);
string a = Console.ReadLine();
if(a == yzm)
       {
break;
       }
}
Console.Read();

 

posted @ 2017-11-02 23:47  _Iniesta  阅读(1356)  评论(0编辑  收藏  举报