int ticks = ~unchecked((int)DateTime.Now.Ticks);
Random Rnd = new Random(ticks);
//保证随机数是 6位长度,数量: 16777215 - 1048576 = 15728639(约1.5千万)
//1048576(10进制) => 100000(16进制)
//16777215(10进制) => ffffff(16进制)
string str_6 = Convert.ToString(Rnd.Next(1048576, 16777215), 16);
Console.WriteLine(str_6);
//保证随机数是 8位长度,数量: int.MaxValue - 268435456 = 1879048191(约18亿)
//268435456(10进制) => 10000000(16进制)
//int.MaxValue(10进制) => 2fffffff(16进制)
string str_8 = Convert.ToString(Rnd.Next(268435456, int.MaxValue), 16);
Console.WriteLine(str_8);