通过本文主要向大家介绍了c#随机数代码,c#随机数生成,c#随机数不重复,c#随机数生成器,c#产生随机数等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
/// 构造随机数 种子
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);
}
/// 生成随机 数
static int rnd()
{
Random ran = new Random(GetRandomSeed());
int cnt = ran.Next(0,59);
return cnt;
}
</div>
以上就是本文的全部内容了,希望大家能够喜欢,能够对大家学习C#有所帮助。
</div>
