c#.net利用RNGCryptoServiceProvider产生任意范围强随机数的办法
int max = 100; //这样产生0 ~ 100的强随机数(含100) int rnd = int.MinValue; decimal _base = (decimal)long.MaxValue; byte[] rndSeries = new byte[8]; System.Security.Cryptography.RNGCryptoServiceProvider rng = new System.Security.Cryptography.RNGCryptoServiceProvider(); rng.GetBytes(rndSeries); rnd = (int)(Math.Abs(BitConverter.ToInt64(rndSeries, 0)) / _base * (max+1)); //不含100需去掉+1
![](http://www1.feedsky.com/t1/304760939/coudly/csdn.net/s.gif?r=http://blog.csdn.net/coudly/archive/2009/11/30/4903021.aspx)