Click or drag to resize
RandomNext Method (Int32, Int32)
Returns a random number within a specified range.

Namespace: System
Assembly: mscorlib (in mscorlib.dll) Version: 4.0.0.0
Syntax
C#
public virtual int Next(
	int minValue,
	int maxValue
)

Parameters

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

Return Value

Type: Int32
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
ExceptionCondition
ArgumentOutOfRangeExceptionminValue is greater than maxValue.
See Also