ThreadSafeRandomSource.Next Method

Definition

Namespace: Numerics.NET.Random
Assembly: Numerics.NET (in Numerics.NET.dll) Version: 10.3.0

Overload List

Next() Returns a non-negative random integer.
Next(Int32) Returns a non-negative random integer less than the specified maximum.
Next(Int32, Int32) Returns a random integer within a specified range.

Next

Returns a non-negative random integer.
C#
public int Next()

Return Value

Int32
A 32-bit signed integer in the range [0, MaxValue).

Implements

IRandomSource.Next()

Next(Int32)

Returns a non-negative random integer less than the specified maximum.
C#
public int Next(
	int maxValue
)

Parameters

maxValue  Int32
The exclusive upper bound of the random number to be generated. maxValue must be greater than or equal to 0.

Return Value

Int32
A 32-bit signed integer in the range [0, maxValue). If maxValue equals 0, returns 0.

Implements

IRandomSource.Next(Int32)

Exceptions

ArgumentOutOfRangeExceptionmaxValue is less than 0.

Next(Int32, Int32)

Returns a random integer within a specified range.
C#
public int Next(
	int minValue,
	int maxValue
)

Parameters

minValue  Int32
The inclusive lower bound of the random number returned.
maxValue  Int32
The exclusive upper bound of the random number returned. maxValue must be greater than or equal to minValue.

Return Value

Int32
A 32-bit signed integer in the range [minValue, maxValue). If minValue equals maxValue, returns minValue.

Implements

IRandomSource.Next(Int32, Int32)

Exceptions

ArgumentOutOfRangeExceptionminValue is greater than maxValue.

See Also