Class RandomExtensions
Provides random data generation.
Namespace: DotNext
Assembly: DotNext.dll
Syntax
public static class RandomExtensions : object
Methods
| Improve this Doc View SourceNext(RandomNumberGenerator)
Generates random non-negative random integer.
Declaration
public static int Next(this RandomNumberGenerator random)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
Returns
Type | Description |
---|---|
Int32 | A 32-bit signed integer that is in range [0, |
NextBoolean(Random, Double)
Generates random boolean value.
Declaration
public static bool NextBoolean(this Random random, double trueProbability = 0.5)
Parameters
Type | Name | Description |
---|---|---|
Random | random | The source of random numbers. |
Double | trueProbability | A probability of true result (should be between 0.0 and 1.0). |
Returns
Type | Description |
---|---|
Boolean | Randomly generated boolean value. |
NextBoolean(RandomNumberGenerator, Double)
Generates random boolean value.
Declaration
public static bool NextBoolean(this RandomNumberGenerator random, double trueProbability = 0.5)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
Double | trueProbability | A probability of true result (should be between 0.0 and 1.0). |
Returns
Type | Description |
---|---|
Boolean | Randomly generated boolean value. |
NextDouble(RandomNumberGenerator)
Returns a random floating-point number that is in range [0, 1).
Declaration
public static double NextDouble(this RandomNumberGenerator random)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
Returns
Type | Description |
---|---|
Double | Randomly generated floating-point number. |
NextString(Random, ReadOnlySpan<Char>, Int32)
Generates random string of the given length.
Declaration
public static string NextString(this Random random, ReadOnlySpan<char> allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
Random | random | The source of random numbers. |
ReadOnlySpan<Char> | allowedChars | The allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |
NextString(Random, Char[], Int32)
Generates random string of the given length.
Declaration
public static string NextString(this Random random, char[] allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
Random | random | The source of random numbers. |
Char[] | allowedChars | The array of allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |
NextString(Random, String, Int32)
Generates random string of the given length.
Declaration
public static string NextString(this Random random, string allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
Random | random | The source of random numbers. |
String | allowedChars | The string of allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |
NextString(RandomNumberGenerator, ReadOnlySpan<Char>, Int32)
Generates random string of the given length.
Declaration
public static string NextString(this RandomNumberGenerator random, ReadOnlySpan<char> allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
ReadOnlySpan<Char> | allowedChars | The allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |
NextString(RandomNumberGenerator, Char[], Int32)
Generates random string of the given length.
Declaration
public static string NextString(this RandomNumberGenerator random, char[] allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
Char[] | allowedChars | The array of allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |
NextString(RandomNumberGenerator, String, Int32)
Generates random string of the given length.
Declaration
public static string NextString(this RandomNumberGenerator random, string allowedChars, int length)
Parameters
Type | Name | Description |
---|---|---|
RandomNumberGenerator | random | The source of random numbers. |
String | allowedChars | The string of allowed characters for the random string. |
Int32 | length | The length of the random string. |
Returns
Type | Description |
---|---|
String | Randomly generated string. |