Method RandomDouble
View SourceRandomDouble()
Returns an infinite sequence of random double values between 0.0 and 1.0
Declaration
public static IAsyncEnumerable<double> RandomDouble()
Returns
Type | Description |
---|---|
IAsyncEnumerable<double> | An infinite sequence of random doubles |
Remarks
The implementation internally uses a shared, thread-local instance of Random to generate a random number on each iteration. The actual Random instance used therefore will depend on the thread on which a single iteration is taking place; that is the call to MoveNext(). If the overall iteration takes place on different threads (e.g. via asynchronous awaits completing on different threads) then various different Random instances will be involved in the generation of the sequence of random numbers. Because the Random instance is shared, if multiple sequences are generated on the same thread, the order of enumeration affects the resulting sequences.
RandomDouble(Random)
Returns an infinite sequence of random double values between 0.0 and 1.0 using the supplied random number generator.
Declaration
public static IAsyncEnumerable<double> RandomDouble(Random rand)
Parameters
Type | Name | Description |
---|---|---|
Random | rand | Generator used to produce random numbers |
Returns
Type | Description |
---|---|
IAsyncEnumerable<double> | An infinite sequence of random doubles |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |