Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness.To browse the .NET Framework source code for this type, see the Reference Source.
More...
|
| Random () |
| Initializes a new instance of the T:System.Random class, using a time-dependent default seed value. More...
|
|
| Random (int Seed) |
| Initializes a new instance of the T:System.Random class, using the specified seed value. More...
|
|
virtual int | Next () |
| Returns a non-negative random integer. More...
|
|
virtual int | Next (int minValue, int maxValue) |
| Returns a random integer that is within a specified range. More...
|
|
virtual int | Next (int maxValue) |
| Returns a non-negative random integer that is less than the specified maximum. More...
|
|
virtual double | NextDouble () |
| Returns a random floating-point number that is greater than or equal to 0.0, and less than 1.0. More...
|
|
virtual void | NextBytes (byte[] buffer) |
| Fills the elements of a specified array of bytes with random numbers. More...
|
|
|
virtual double | Sample () |
| Returns a random floating-point number between 0.0 and 1.0. More...
|
|
Represents a pseudo-random number generator, which is a device that produces a sequence of numbers that meet certain statistical requirements for randomness.To browse the .NET Framework source code for this type, see the Reference Source.
Definition at line 9 of file Random.cs.
◆ Random() [1/2]
Initializes a new instance of the T:System.Random class, using a time-dependent default seed value.
Definition at line 25 of file Random.cs.
◆ Random() [2/2]
System.Random.Random |
( |
int |
Seed | ) |
|
Initializes a new instance of the T:System.Random class, using the specified seed value.
- Parameters
-
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. |
Definition at line 33 of file Random.cs.
◆ Next() [1/3]
virtual int System.Random.Next |
( |
| ) |
|
|
virtual |
Returns a non-negative random integer.
- Returns
- A 32-bit signed integer that is greater than or equal to 0 and less than F:System.Int32.MaxValue.
Definition at line 104 of file Random.cs.
◆ Next() [2/3]
virtual int System.Random.Next |
( |
int |
minValue, |
|
|
int |
maxValue |
|
) |
| |
|
virtual |
Returns a random integer that is within a specified range.
- Parameters
-
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.
- Exceptions
-
T:System.ArgumentOutOfRangeException | minValue is greater than maxValue . |
Definition at line 128 of file Random.cs.
◆ Next() [3/3]
virtual int System.Random.Next |
( |
int |
maxValue | ) |
|
|
virtual |
Returns a non-negative random integer that is less than the specified maximum.
- Parameters
-
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.
- Exceptions
-
T:System.ArgumentOutOfRangeException | maxValue is less than 0. |
Definition at line 148 of file Random.cs.
◆ NextBytes()
virtual void System.Random.NextBytes |
( |
byte [] |
buffer | ) |
|
|
virtual |
Fills the elements of a specified array of bytes with random numbers.
- Parameters
-
buffer | An array of bytes to contain random numbers. |
- Exceptions
-
T:System.ArgumentNullException | buffer is null . |
Definition at line 170 of file Random.cs.
◆ NextDouble()
virtual double System.Random.NextDouble |
( |
| ) |
|
|
virtual |
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.
Definition at line 160 of file Random.cs.
◆ Sample()
virtual double System.Random.Sample |
( |
| ) |
|
|
protectedvirtual |
Returns a random floating-point number between 0.0 and 1.0.
- Returns
- A double-precision floating point number that is greater than or equal to 0.0, and less than 1.0.
Definition at line 69 of file Random.cs.
The documentation for this class was generated from the following file: