MoreEnumerableRandom Method (Int32) |
Returns an infinite sequence of random integers between zero and
a given maximum.
Namespace:
MoreLinq
Assembly:
MoreLinq (in MoreLinq.dll) Version: 3.3.1+b77df70598ab84c28cd43dcf74594024b6d575e1
Syntax public static IEnumerable<int> Random(
int maxValue
)
Public Shared Function Random (
maxValue As Integer
) As IEnumerable(Of Integer)
public:
static IEnumerable<int>^ Random(
int maxValue
)
static member Random :
maxValue : int -> IEnumerable<int>
Parameters
- maxValue
- Type: SystemInt32
exclusive upper bound for the random values returned
Return Value
Type:
IEnumerableInt32An infinite sequence of random integers
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.
See Also