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

/// <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));
}
}

 

posted @ 2018-10-13 13:07 薛定谔家的猫 阅读(...) 评论(...) 编辑 收藏