代码如下:
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();
以上这篇C#验证码问题的快速解决方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持phpstudy。
本文地址:https://www.stayed.cn/item/6404
转载请注明出处。
本站部分内容来源于网络,如侵犯到您的权益,请 联系我