Provides random data generation.
InheritanceRandomExtensions
Namespace: DotNext Assembly: DotNext.dll Syntaxpublic static class RandomExtensions
Methods | Edit this page View Source GetItems<T>(Random, Span<T>)
Fills the buffer with random values of the specified type.
Declarationpublic static void GetItems<T>(this Random random, Span<T> buffer) where T : unmanaged
Parameters Type Name Description Random random
The source of random numbers.
Span<T> bufferThe buffer to fill with random values.
Type Parameters Name Description TThe blittable type.
Exceptions | Edit this page View Source GetItems<T>(RandomNumberGenerator, Span<T>)Fills the buffer with random values of the specified type.
Declarationpublic static void GetItems<T>(this RandomNumberGenerator random, Span<T> buffer) where T : unmanaged
Parameters Type Name Description RandomNumberGenerator random
The source of random numbers.
Span<T> bufferThe buffer to fill with random values.
Type Parameters Name Description TThe blittable type.
Exceptions | Edit this page View Source Next(RandomNumberGenerator)Generates non-negative integer.
Declarationpublic static int Next(this RandomNumberGenerator random)
Parameters Returns Type Description int
A 32-bit signed integer that is in range [0, MaxValue).
| Edit this page View Source NextBoolean(Random, double)Generates a random boolean value.
Declarationpublic static bool NextBoolean(this Random random, double trueProbability = 0.5)
Parameters Type Name Description Random random
The source of random numbers.
double trueProbabilityA probability of true result (should be between 0.0 and 1.0).
Returns Type Description boolRandomly generated boolean value.
Exceptions | Edit this page View Source NextBoolean(RandomNumberGenerator, double)Generates a random boolean value.
Declarationpublic static bool NextBoolean(this RandomNumberGenerator random, double trueProbability = 0.5)
Parameters Type Name Description RandomNumberGenerator random
The source of random numbers.
double trueProbabilityA probability of true result (should be between 0.0 and 1.0).
Returns Type Description boolRandomly generated boolean value.
Exceptions | Edit this page View Source NextChars(Random, ReadOnlySpan<char>, Span<char>)Generates a random set of characters.
Declarationpublic static void NextChars(this Random random, ReadOnlySpan<char> allowedChars, Span<char> buffer)
Parameters Type Name Description Random random
The source of random numbers.
ReadOnlySpan<char> allowedCharsThe allowed characters for the random string.
Span<char> bufferThe array to be filled with random characters.
Exceptions | Edit this page View Source NextChars(RandomNumberGenerator, ReadOnlySpan<char>, Span<char>)Generates a random set of characters.
Declarationpublic static void NextChars(this RandomNumberGenerator random, ReadOnlySpan<char> allowedChars, Span<char> buffer)
Parameters Exceptions | Edit this page View Source NextDouble(RandomNumberGenerator)
Returns a random floating-point number that is in range [0, 1).
Declarationpublic static double NextDouble(this RandomNumberGenerator random)
Parameters Returns Type Description double
Randomly generated floating-point number.
| Edit this page View Source NextString(Random, ReadOnlySpan<char>, int)Generates a random string of the given length.
Declarationpublic static string NextString(this Random random, ReadOnlySpan<char> allowedChars, int length)
Parameters Type Name Description Random random
The source of random numbers.
ReadOnlySpan<char> allowedCharsThe allowed characters for the random string.
int lengthThe length of the random string.
Returns Type Description stringRandomly generated string.
Exceptions | Edit this page View Source NextString(Random, string, int)Generates a random string of the given length.
Declarationpublic static string NextString(this Random random, string allowedChars, int length)
Parameters Type Name Description Random random
The source of random numbers.
string allowedCharsThe string of allowed characters for the random string.
int lengthThe length of the random string.
Returns Type Description stringRandomly generated string.
Exceptions | Edit this page View Source NextString(RandomNumberGenerator, ReadOnlySpan<char>, int)Generates a random string of the given length.
Declarationpublic static string NextString(this RandomNumberGenerator random, ReadOnlySpan<char> allowedChars, int length)
Parameters Type Name Description RandomNumberGenerator random
The source of random numbers.
ReadOnlySpan<char> allowedCharsThe allowed characters for the random string.
int lengthThe length of the random string.
Returns Type Description stringRandomly generated string.
Exceptions | Edit this page View Source NextString(RandomNumberGenerator, string, int)Generates a random string of the given length.
Declarationpublic static string NextString(this RandomNumberGenerator random, string allowedChars, int length)
Parameters Type Name Description RandomNumberGenerator random
The source of random numbers.
string allowedCharsThe string of allowed characters for the random string.
int lengthThe length of the random string.
Returns Type Description stringRandomly generated string.
Exceptions | Edit this page View Source Next<T>(Random)Generates a random value of blittable type.
Declarationpublic static T Next<T>(this Random random) where T : unmanaged
Parameters Type Name Description Random random
The source of random numbers.
Returns Type Description TThe randomly generated value.
Type Parameters Name Description TThe blittable type.
| Edit this page View Source Next<T>(RandomNumberGenerator)Generates a random value of blittable type.
Declarationpublic static T Next<T>(this RandomNumberGenerator random) where T : unmanaged
Parameters Returns Type Description T
The randomly generated value.
Type Parameters Name Description TThe blittable type.
| Edit this page View Source Peek<T>(Random, IReadOnlyCollection<T>)Gets the random element from the collection.
Declarationpublic static Optional<T> Peek<T>(this Random random, IReadOnlyCollection<T> collection)
Parameters Type Name Description Random random
The random numbers source.
IReadOnlyCollection<T> collectionThe collection to get the random element.
Returns Type Description Optional<T>The random element from the collection; or None if collection is empty.
Type Parameters Name Description TThe type of elements in the collection.
| Edit this page View Source Peek<T>(Random, ReadOnlySpan<T>)Chooses the random element in the span.
Declarationpublic static Optional<T> Peek<T>(this Random random, ReadOnlySpan<T> span)
Parameters Type Name Description Random random
The source of random values.
ReadOnlySpan<T> spanThe span of elements.
Returns Type Description Optional<T>Randomly selected element from the span; or None if span is empty.
Type Parameters Name Description TThe type of elements in the span.
| Edit this page View Source Shuffle<T>(Random, IList<T>)Randomizes elements in the list.
Declarationpublic static void Shuffle<T>(this Random random, IList<T> list)
Parameters Type Name Description Random random
The source of random values.
IList<T> listThe list to shuffle.
Type Parameters Name Description TThe type of items in the list.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4