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
TThe 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
countintThe 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
minTThe minimum value of the range.
maxTThe maximum value of the range.
countintThe number of elements in the random array.
Exceptions
- ArgumentException
Thrown when
minis 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.