DotNext by .NET Foundation and Contributors

<PackageReference Include="DotNext" Version="5.8.0" />

.NET API 503,240 bytes

 RandomExtensions

public static class RandomExtensions
Provides random data generation.
public static void GetItems<T>(this Random random, Span<T> buffer) where T : ValueType modreq(System.Runtime.InteropServices.UnmanagedType)

Fills the buffer with random values of the specified type.

Fills the buffer with random values of the specified type.

public static int Next(this RandomNumberGenerator random)

Generates non-negative integer.

Generates a random value of blittable type.

Generates a random value of blittable type.

public static bool NextBoolean(this Random random, double trueProbability = 0.5)

Generates a random boolean value.

public static bool NextBoolean(this RandomNumberGenerator random, double trueProbability = 0.5)

Generates a random boolean value.

public static void NextChars(this Random random, ReadOnlySpan<char> allowedChars, Span<char> buffer)

Generates a random set of characters.

public static void NextChars(this RandomNumberGenerator random, ReadOnlySpan<char> allowedChars, Span<char> buffer)

Generates a random set of characters.

public static double NextDouble(this RandomNumberGenerator random)

Returns a random floating-point number that is in range [0, 1).

public static string NextString(this Random random, ReadOnlySpan<char> allowedChars, int length)

Generates a random string of the given length.

public static string NextString(this Random random, string allowedChars, int length)

Generates a random string of the given length.

public static string NextString(this RandomNumberGenerator random, ReadOnlySpan<char> allowedChars, int length)

Generates a random string of the given length.

public static string NextString(this RandomNumberGenerator random, string allowedChars, int length)

Generates a random string of the given length.

public static Optional<T> Peek<T>(this Random random, IReadOnlyCollection<T> collection)

Gets the random element from the collection.

public static Optional<T> Peek<T>(this Random random, ReadOnlySpan<T> span)

Chooses the random element in the span.

public static void Shuffle<T>(this Random random, IList<T> list)

Randomizes elements in the list.