C#产生不重复随机数

时间:2014-05-12 16:10:44   收藏:0   阅读:269

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


Random random = new Random( GetRandomSeed( ) ); 

C#产生不重复随机数,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!