Namespace: System
Random
Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness.
Methods (6)
Random(Int32)Constructor
Initializes a new instance of the Random class, using the specified seed value.
| Parameter | Description |
|---|---|
| Seed | A number used to calculate a starting value for the pseudo-random number sequence. If a negative number is specified, the absolute value of the number is used. |
int Next
Returns a non-negative random integer.
Returns: A 32-bit signed integer that is greater than or equal to 0 and less than MaxValue.
int Next(Int32)
Returns a non-negative random integer that is less than the specified maximum.
| Parameter | Description |
|---|---|
| maxValue | The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0. |
Returns: A 32-bit signed integer that is greater than or equal to 0, and less than maxValue; that is, the range of return values ordinarily includes 0 but not maxValue. However, if maxValue equals 0, maxValue is returned.
int Next(Int32,Int32)
Returns a random integer that is within a specified range.
| Parameter | Description |
|---|---|
| minValue | The inclusive lower bound of the random number returned. |
| maxValue | The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue. |
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.
double NextDouble
Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0.
Returns: A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
void NextBytes(Byte[])
Fills the elements of a specified array of bytes with random numbers.
| Parameter | Description |
|---|---|
| buffer | An array of bytes to contain random numbers. |