Mono Class Library: System.Random Overview | Members

System.Random.Next Method

Returns a psuedo-random positive number less than the specified maximum.

public virtual int Next (int maxValue)

Parameters

maxValue
The upper bound of the random number to be generated. maxValue is required to be greater than or equal to zero.

Returns

A int set to a psuedo-random value greater than or equal to zero and less than maxValue. If maxValue is zero, returns zero.

Exceptions

TypeReason
ArgumentOutOfRangeExceptionmaxValue is less than zero.

Remarks

Operation
As described above.

Note to Inheritors
Override this method to customize the algorithm used to generate the return value.

Usage
Use this method to generate a psuedo-random number less than the specified maximum value.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0