c# 获取随机种子不重复
本文关键字: c#, 种子, 随机直接上代码:亲测不重复。
Random ran = new Random(GetRandomSeed());
int RandKey = ran.Next(0, 1000);static int GetRandomSeed()
{
byte[] bytes = new byte[4];
System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider();
rng.GetBytes(bytes);
return BitConverter.ToInt32(bytes, 0);
}