Table of Contents

Class RandomArray<T>

Namespace
Ecng.Common
Assembly
Ecng.Common.dll

Provides functionality to generate a random array of values of type T.

public class RandomArray<T> where T : struct, IComparable<T>

Type Parameters

T

The type of the elements in the array. Must be a value type that implements IComparable.

Inheritance
RandomArray<T>
Inherited Members
Extension Methods

Constructors

RandomArray(int)

Initializes a new instance of the RandomArray<T> class with a specified count.

public RandomArray(int count)

Parameters

count int

The number of elements in the random array.

Exceptions

NotSupportedException

Thrown when type T is not supported for random generation.

RandomArray(T, T, int)

Initializes a new instance of the RandomArray<T> class within a specified range.

public RandomArray(T min, T max, int count)

Parameters

min T

The minimum value of the range.

max T

The maximum value of the range.

count int

The number of elements in the random array.

Exceptions

ArgumentException

Thrown when min is greater than max.

NotSupportedException

Thrown when type T is not supported for ranged random generation.

Properties

Count

Gets the total number of elements in the random array.

public int Count { get; }

Property Value

int

Max

Gets the maximum value used in the random array generation.

public T Max { get; }

Property Value

T

Min

Gets the minimum value (or default seed value) used in the random array generation.

public T Min { get; }

Property Value

T

Methods

Next()

Returns the next random element from the array.

public T Next()

Returns

T

A random element of type T from the array.