时间:2020-11-05 17:57:07 | 栏目:.NET代码 | 点击:次
代码如下:
string ss = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; Random a = new Random(); int b; string yan = ""; for (int i = 0; i < 4; i++) { b = a.Next(62); yan += ss.Substring(b, 1); } Console.WriteLine("验证码是:" + yan); Console.Write("请输入验证码:"); string c = Console.ReadLine(); if (c.ToUpper() == yan.ToUpper()) { Console.WriteLine("验证码正确!"); } else { Console.WriteLine("验证码错误!"); } Console.ReadLine();