コード例 #1
0
        /// <summary>
        /// Returns a random integer that is within a specified range.
        /// </summary>
        /// <param name="min">The inclusive lower bound of the random number returned.</param>
        /// <param name="max">The exclusive upper bound of the random number returned. maxValue must be greater
        /// than or equal to minValue.</param>
        /// <returns>A 32-bit signed integer greater than or equal to minValue and less than maxValue;
        /// that is, the range of return values includes minValue but not maxValue. If minValue
        /// equals maxValue, minValue is returned.</returns>
        public static int GetRandomNumber(int min, int max)
        {
            var threadSafeRandom = new ThreadSafeRandom();

            return(threadSafeRandom.Next(min, max));
        }
コード例 #2
0
        /// <summary>
        /// Returns a non-negative random integer.
        /// </summary>
        /// <returns>A 32-bit signed integer that is greater than or equal to 0 and less than System.Int32.MaxValue.</returns>
        public static int GetRandomNumber()
        {
            var threadSafeRandom = new ThreadSafeRandom();

            return(threadSafeRandom.Next());
        }