RandomGen
Provides methods for generating random values of various types.
Методы
public static bool GetBool()
result = RandomGen.GetBool()
Returns a random boolean value.
Возвращает: A random boolean.
public static byte GetByte(byte min, byte max)
result = RandomGen.GetByte(min, max)
Returns a random byte between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random byte between min and max.
public static byte GetByte(byte max)
result = RandomGen.GetByte(max)
Returns a random byte between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random byte between 0 and max.
public static byte GetByte()
result = RandomGen.GetByte()
Returns a random byte between 0 and byte.MaxValue.
Возвращает: A random byte.
public static byte[] GetBytes(int count)
result = RandomGen.GetBytes(count)
Returns an array of random bytes with the specified count.
- count
- The number of random bytes to generate.
Возвращает: An array of random bytes.
public static void GetBytes(byte[] buffer)
RandomGen.GetBytes(buffer)
Fills the provided array with random bytes.
- buffer
- The array to fill with random bytes.
public static DateTime GetDate(DateTime min, DateTime max)
result = RandomGen.GetDate(min, max)
Returns a random DateTime value between the specified minimum and maximum values.
- min
- The minimum DateTime value.
- max
- The maximum DateTime value.
Возвращает: A random DateTime between min and max.
public static DateTime GetDate()
result = RandomGen.GetDate()
Returns a random DateTime value between DateTime.MinValue and DateTime.MaxValue.
Возвращает: A random DateTime.
public static decimal GetDecimal(decimal min, decimal max, int precision)
result = RandomGen.GetDecimal(min, max, precision)
Returns a random decimal value between the specified minimum and maximum values with the given precision.
- min
- The minimum decimal value.
- max
- The maximum decimal value.
- precision
- The number of decimal places to round the value to.
Возвращает: A random decimal value between min and max rounded to the specified precision.
public static decimal GetDecimal(int integer, int fractional)
result = RandomGen.GetDecimal(integer, fractional)
Returns a random non-zero decimal value with a specified number of integer and fractional digits. Tries up to 10 times to generate a valid number.
- integer
- The maximum number of digits in the integer part. Default is 8.
- fractional
- The maximum number of digits in the fractional part. Default is 8.
Возвращает: A random decimal value.
public static double GetDouble()
result = RandomGen.GetDouble()
Returns a random double value between 0.0 and 1.0.
Возвращает: A random double.
public static double GetDouble(double max)
result = RandomGen.GetDouble(max)
Returns a random double value between 0.0 and the specified maximum value.
- max
- The maximum value.
Возвращает: A random double between 0.0 and max.
public static double GetDouble(double min, double max)
result = RandomGen.GetDouble(min, max)
Returns a random double value between the specified minimum and maximum values.
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random double between min and max.
public static T GetElement<T>(IEnumerable<T> array)
result = RandomGen.GetElement(array)
Returns a random element from the specified collection.
- array
- The collection of elements.
Возвращает: A random element from the collection.
public static object GetEnum(Type enumType)
result = RandomGen.GetEnum(enumType)
Returns a random enum value from the specified enum type.
- enumType
- The enum type.
Возвращает: A random enum value.
public static T GetEnum<T>(T min, T max)
result = RandomGen.GetEnum(min, max)
Returns a random enum value between the specified minimum and maximum enum values.
- min
- The minimum enum value.
- max
- The maximum enum value.
Возвращает: A random enum value between min and max.
public static T GetEnum<T>()
result = RandomGen.GetEnum()
Returns a random enum value of type T.
Возвращает: A random enum value.
public static T GetEnum<T>(IEnumerable<T> values)
result = RandomGen.GetEnum(values)
Returns a random enum value from the specified collection of values.
- values
- A collection of enum values.
Возвращает: A random enum value from the collection.
public static float GetFloat()
result = RandomGen.GetFloat()
Returns a random single-precision floating-point number between 0.0 and 1.0.
Возвращает: A random float.
public static float GetFloat(float min, float max)
result = RandomGen.GetFloat(min, max)
Returns a random single-precision floating-point number between the specified minimum and maximum values.
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random float between min and max.
public static float GetFloat(float max)
result = RandomGen.GetFloat(max)
Returns a random single-precision floating-point number between 0.0 and the specified maximum value.
- max
- The maximum value.
Возвращает: A random float between 0.0 and max.
public static int GetInt(int max)
result = RandomGen.GetInt(max)
Returns a random integer between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random integer between 0 and max (inclusive).
public static int GetInt()
result = RandomGen.GetInt()
Returns a random non-negative integer.
Возвращает: A random integer.
public static int GetInt(int min, int max)
result = RandomGen.GetInt(min, max)
Returns a random integer between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random integer between min and max (inclusive).
public static long GetLong(long min, long max)
result = RandomGen.GetLong(min, max)
Returns a random long value between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random long value between min and max (inclusive).
public static long GetLong()
result = RandomGen.GetLong()
Returns a random long value between long.MinValue and long.MaxValue.
Возвращает: A random long value.
public static sbyte GetSByte()
result = RandomGen.GetSByte()
Returns a random signed byte between sbyte.MinValue and sbyte.MaxValue.
Возвращает: A random signed byte.
public static sbyte GetSByte(sbyte min, sbyte max)
result = RandomGen.GetSByte(min, max)
Returns a random signed byte between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random signed byte between min and max.
public static sbyte GetSByte(sbyte max)
result = RandomGen.GetSByte(max)
Returns a random signed byte between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random signed byte between 0 and max.
public static short GetShort(short min, short max)
result = RandomGen.GetShort(min, max)
Returns a random 16-bit signed integer between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random short value between min and max.
public static short GetShort()
result = RandomGen.GetShort()
Returns a random 16-bit signed integer between short.MinValue and short.MaxValue.
Возвращает: A random short value.
public static short GetShort(short max)
result = RandomGen.GetShort(max)
Returns a random 16-bit signed integer between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random short value between 0 and max.
public static string GetString(int min, int max)
result = RandomGen.GetString(min, max)
Returns a random Base64 encoded string generated from a random salt.
- min
- The minimum length for generating the salt.
- max
- The maximum length for generating the salt.
Возвращает: A random Base64 encoded string.
public static TimeSpan GetTime()
result = RandomGen.GetTime()
Returns a random TimeSpan value between TimeSpan.MinValue and TimeSpan.MaxValue.
Возвращает: A random TimeSpan.
public static TimeSpan GetTime(TimeSpan min, TimeSpan max)
result = RandomGen.GetTime(min, max)
Returns a random TimeSpan value between the specified minimum and maximum values.
- min
- The minimum TimeSpan value.
- max
- The maximum TimeSpan value.
Возвращает: A random TimeSpan between min and max.
public static uint GetUInt()
result = RandomGen.GetUInt()
Returns a random unsigned integer between 0 and uint.MaxValue.
Возвращает: A random unsigned integer.
public static uint GetUInt(uint min, uint max)
result = RandomGen.GetUInt(min, max)
Returns a random unsigned integer between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random unsigned integer between min and max.
public static uint GetUInt(uint max)
result = RandomGen.GetUInt(max)
Returns a random unsigned integer between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random unsigned integer between 0 and max.
public static ulong GetULong(ulong min, ulong max)
result = RandomGen.GetULong(min, max)
Returns a random unsigned long value between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random unsigned long value between min and max.
public static ulong GetULong(ulong max)
result = RandomGen.GetULong(max)
Returns a random unsigned long value between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random unsigned long value between 0 and max.
public static ulong GetULong()
result = RandomGen.GetULong()
Returns a random unsigned long value between 0 and ulong.MaxValue.
Возвращает: A random unsigned long value.
public static ushort GetUShort()
result = RandomGen.GetUShort()
Returns a random 16-bit unsigned integer between 0 and ushort.MaxValue.
Возвращает: A random unsigned short value.
public static ushort GetUShort(ushort min, ushort max)
result = RandomGen.GetUShort(min, max)
Returns a random 16-bit unsigned integer between the specified minimum and maximum values (inclusive).
- min
- The minimum value.
- max
- The maximum value.
Возвращает: A random unsigned short value between min and max.
public static ushort GetUShort(ushort max)
result = RandomGen.GetUShort(max)
Returns a random 16-bit unsigned integer between 0 and the specified maximum value (inclusive).
- max
- The maximum value.
Возвращает: A random unsigned short value between 0 and max.