Show / Hide Table of Contents

Interface IRandom

An pseudorandom number generator interface equivalent to System.Random.

Although these two types have similar shapes, they are not compatible (i.e., disallowed to be casted to each other).

Namespace: Libplanet.Action
Assembly: Libplanet.Action.dll
Syntax
public interface IRandom

Properties

| Improve this Doc View Source

Seed

A number used to calculate a starting value for the pseudo-random number sequence.

Declaration
[Pure]
int Seed { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

Next()

Gets a non-negative random integer.

Declaration
int Next()
Returns
Type Description
Int32

A 32-bit signed integer that is greater than or equal to 0 and less than MaxValue.

See Also
Next()
| Improve this Doc View Source

Next(Int32, Int32)

Gets a random integer that is within a specified range.

Declaration
int Next(int lowerBound, int upperBound)
Parameters
Type Name Description
Int32 lowerBound

The inclusive lower bound of the random number to be generated.

Int32 upperBound

The exclusive upper bound of the random number to be generated. It must be greater than or equal to lowerBound.

Returns
Type Description
Int32

A 32-bit signed integer that is greater than or equal to lowerBound and less than upperBound; that is, the range of return values ordinarily includes lowerBound but not upperBound. If upperBound equals to lowerBound, lowerBound is returned.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when upperBound is less than lowerBound.

See Also
Next(Int32, Int32)
| Improve this Doc View Source

Next(Int32)

Gets a non-negative random integer that is less than the specified upperBound.

Declaration
int Next(int upperBound)
Parameters
Type Name Description
Int32 upperBound

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

Returns
Type Description
Int32

A 32-bit signed integer that is greater than or equal to 0 and less than upperBound; that is, the range of return values ordinarily includes 0 but not upperBound. However, if upperBound equals to 0, upperBound is returned.

Exceptions
Type Condition
ArgumentOutOfRangeException

Thrown when upperBound is less than 0.

See Also
System.Random.Next(System.Int32)
| Improve this Doc View Source

NextBytes(Byte[])

Fills the elements of a specified System.Bytes buffer with random numbers.

Declaration
void NextBytes(byte[] buffer)
Parameters
Type Name Description
System.Byte[] buffer

A System.Byte array to contain random numbers.

Exceptions
Type Condition
System.ArgumentNullException

Thrown when buffer is null.

See Also
NextBytes(Byte[])

Extension Methods

RandomExtensions.GenerateRandomGuid(IRandom)
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium