Skip to main content

Random

Namespace: MonineEngine.Core

Wrapper class for random value generation. All random number generation used is thread-safe, but does not have control over the seed. If you want to use a custom seed for randomization, it's better to manage instances instead.

public static class Random

Inheritance ObjectRandom
Attributes NullableContextAttribute, NullableAttribute

Fields

Seed

The current seed of the random number generation.

public static int Seed;

Remarks:

This currently does not work, and will always remain at 0.

Properties

Current

Gets the Random being used. This defaults to Random.Shared on initialization.

public static Random Current { get; }

Property Value

Random

Methods

Range(Int32, Int32)

Generates and returns a random integer in the specified range.

public static int Range(int min, int max)

Parameters

min Int32
The inclusive minimum number in the range.

max Int32
The inclusive maximum number in the range.

Returns

Int32
A random integer between the specified minimum and maximum.

Range()

Generates and returns a non-negative random integer.

public static int Range()

Returns

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

Range(Single, Single)

Generates and returns a random float in the specified range.

public static float Range(float min, float max)

Parameters

min Single
The inclusive minimum number in the range.

max Single
The inclusive maximum number in the range.

Returns

Single
A random float between the specified minimum and maximum.

Range(Double, Double)

Generates and returns a random double in the specified range.

public static double Range(double min, double max)

Parameters

min Double
The minimum number in the range.

max Double
The maximum number in the range.

Returns

Double
A random float between the specified minimum and maximum.

RandomBytes(Int32)

Generates and returns an array of random bytes, with the specified array length.

public static Byte[] RandomBytes(int length)

Parameters

length Int32
The length of the byte array.

Returns

Byte[]
An array of bytes of the specified length, with each element having a random value.

RandomRGB()

Generates and returns a random RGB Color.

public static Color RandomRGB()

Returns

Color
A new Color with random RGB values.

RandomRGBA()

Generates and returns a random RGBA Color.

public static Color RandomRGBA()

Returns

Color
A new Color with random RGBA values.