public static int GetRandom(int pMinVal = 0, int pMaxVal = int.MaxValue)
        {
            int m = pMaxVal - pMinVal;
            int rnd = int.MinValue;
            decimal _base = (decimal)long.MaxValue;
            byte[] rndSeries = new byte[8];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            rng.GetBytes(rndSeries);
            long l = BitConverter.ToInt64(rndSeries, 0);
            rnd = (int)(Math.Abs(l) / _base * m);
            return pMinVal + rnd;
        }

 

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2021-06-17
  • 2022-12-23
  • 2021-09-01
  • 2021-06-22
  • 2022-12-23
  • 2021-07-07
猜你喜欢
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
相关资源
相似解决方案