标签:ar for 数据 sp c r new bs 数据库
Random random = new Random(~unchecked((int)DateTime.Now.Ticks));
private string CreateAndCheckCode(Random random, string code, int length) // code 激活码前缀
{
char[] Pattern = new char[] { ‘0‘, ‘1‘, ‘2‘, ‘3‘, ‘4‘, ‘5‘, ‘6‘, ‘7‘, ‘8‘, ‘9‘, ‘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‘ };
string result = code;
int n = Pattern.Length;
for (int i = 0; i < length; i++)
{
int rnd = random.Next(0, n);
result += Pattern[rnd];
}
if (数据库中不存在)
{
return result;
}
else
{
return CreateAndCheckCode(random, code, length);
}
}
标签:ar for 数据 sp c r new bs 数据库
原文地址:http://www.cnblogs.com/flywing/p/3998249.html