Edit

Share via


Random.Shuffle Method

Definition

Overloads

Shuffle<T>(Span<T>)

Performs an in-place shuffle of a span.

Shuffle<T>(T[])

Performs an in-place shuffle of an array.

Shuffle<T>(Span<T>)

Source:
Random.cs
Source:
Random.cs

Performs an in-place shuffle of a span.

public:
generic <typename T>
 void Shuffle(Span<T> values);
public void Shuffle<T> (Span<T> values);
member this.Shuffle : Span<'T> -> unit
Public Sub Shuffle(Of T) (values As Span(Of T))

Type Parameters

T

The type of span.

Parameters

values
Span<T>

The span to shuffle.

Remarks

This method uses Next(Int32, Int32) to choose values for shuffling. This method is an O(n) operation.

Applies to

Shuffle<T>(T[])

Source:
Random.cs
Source:
Random.cs

Performs an in-place shuffle of an array.

public:
generic <typename T>
 void Shuffle(cli::array <T> ^ values);
public void Shuffle<T> (T[] values);
member this.Shuffle : 'T[] -> unit
Public Sub Shuffle(Of T) (values As T())

Type Parameters

T

The type of array.

Parameters

values
T[]

The array to shuffle.

Exceptions

values is null.

Remarks

This method uses Next(Int32, Int32) to choose values for shuffling. This method is an O(n) operation.

Applies to