欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

c# 解决Randoms伪随机重复问题

程序员文章站 2022-05-12 13:01:01
/// /// 解决伪随机问题 /// public static void Random() { int t = 0; for (int i = 0; i < 10; i++) { byte[] bytes = new byte[4]; System.Security.Cryptography.R... ......
/// <summary>
/// 解决伪随机问题
/// </summary>
public static void random()
{
int t = 0;
for (int i = 0; i < 10; i++)
{
byte[] bytes = new byte[4];
system.security.cryptography.rngcryptoserviceprovider rng = new system.security.cryptography.rngcryptoserviceprovider();
rng.getbytes(bytes);
t = bitconverter.toint32(bytes, 0);
random rnd = new random(t);
console.writeline(rnd.next(0, 10));
}
}