Class RandomArray<T>
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
intThe 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
TThe minimum value of the range.
max
TThe maximum value of the range.
count
intThe number of elements in the random array.
Exceptions
- ArgumentException
Thrown when
min
is greater thanmax
.- 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
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.