RandomNumber Method
Definition
RandomNumber(int)
Generates a random integer that is within a specified range.
public static int RandomNumber(int maximumExclusive = 2147483647)
Parameters
maximumExclusiveintThe exclusive upper bound of the random number returned.
maximumExclusivemust be greater than or equal to 0.
Returns
- int
A 32-bit signed integer greater than or equal to 0 and less than
maximumExclusive; that is, the range of return values includes 0 but notmaximumExclusive. If 0 equalsmaximumExclusive, 0 is returned.
RandomNumber(int, int)
Generates a random integer that is within a specified range.
public static int RandomNumber(int minimumInclusive, int maximumExclusive)
Parameters
minimumInclusiveintThe inclusive lower bound of the random number returned.
maximumExclusiveintThe exclusive upper bound of the random number returned.
maximumExclusivemust be greater than or equal tominimumInclusive.
Returns
- int
A 32-bit signed integer greater than or equal to
minimumInclusiveand less thanmaximumExclusive; that is, the range of return values includesminimumInclusivebut notmaximumExclusive. IfminimumInclusiveequalsmaximumExclusive,minimumInclusiveis returned.
Exceptions
- ArgumentOutOfRangeException
minimumInclusiveis greater thanmaximumExclusive.