5.20 c#验证码练习
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication10 { class Program { static void Main(string[] args) { Random ran = new Random(); for (; ; ) { string aa = "", bb = ""; for (int l = 1; l <= 4; l++) { int b = ran.Next(36); string[] c = new string[36] {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q", "R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7" ,"8","9","0"}; aa = c[b]; bb += aa; } Console.WriteLine("验证码是:" + bb); Console.Write("请输入验证码"); string ma = Console.ReadLine(); ma = ma.ToUpper(); if (ma == bb) { Console.WriteLine("验证码输入正确"); break; } else { Console.WriteLine("输入有误请重新输入"); } Console.ReadLine(); } } } }