1:随机数的基数为大写字母26个,和数字0-9
namespace test
{
class Program
{
static void Main(string[] args)
{
string result = string.Empty;
string[] arrString = { "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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", };
Random rd = new Random();
for (int i = 0; i < 8; i++)
{
result += arrString[rd.Next(arrString.Length-1)];
}
Console.WriteLine(result);
Console.ReadLine();
}
}
}
{
class Program
{
static void Main(string[] args)
{
string result = string.Empty;
string[] arrString = { "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", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", };
Random rd = new Random();
for (int i = 0; i < 8; i++)
{
result += arrString[rd.Next(arrString.Length-1)];
}
Console.WriteLine(result);
Console.ReadLine();
}
}
}