/// <summary>
/// 产生N个字符组成的字符串:数字+字母
/// </summary>
/// <param name="count">N个字符</param>
/// <returns></returns>
private static string RandomFourChar(int N)
{
Random random = new Random();
string randomCodeString = string.Empty;
for (int i = 0; i < N; i++)
{
int a = random.Next(0, 26);
char characterCode = (char)('A' + (char)a);
int b = random.Next(0, 10);
int c = random.Next(0, 2);//随机数不能取上限界值。
if (c == 0)
{
randomCodeString += characterCode;
}
else
{
randomCodeString += b;
}
}
return randomCodeString;
}
产生N个字符组成的字符串:数字+字母
最新推荐文章于 2021-12-15 22:30:40 发布