Random.GetItems 方法

定義

多載

GetItems<T>(ReadOnlySpan<T>, Int32)

從提供的一組選擇中,建立以隨機播放專案填入的陣列。

GetItems<T>(ReadOnlySpan<T>, Span<T>)

使用從提供的一組選擇中隨機播放的專案,填入指定範圍的專案。

GetItems<T>(T[], Int32)

從提供的一組選擇中,建立以隨機播放專案填入的陣列。

GetItems<T>(ReadOnlySpan<T>, Int32)

來源:
Random.cs
來源:
Random.cs

從提供的一組選擇中,建立以隨機播放專案填入的陣列。

public:
generic <typename T>
 cli::array <T> ^ GetItems(ReadOnlySpan<T> choices, int length);
public T[] GetItems<T> (ReadOnlySpan<T> choices, int length);
member this.GetItems : ReadOnlySpan<'T> * int -> 'T[]
Public Function GetItems(Of T) (choices As ReadOnlySpan(Of T), length As Integer) As T()

類型參數

T

陣列的類型。

參數

choices
ReadOnlySpan<T>

要用來填入陣列的專案。

length
Int32

要傳回的陣列長度。

傳回

T[]

填入隨機專案的陣列。

例外狀況

choices 是空的。

length 不是零或正數。

備註

方法會使用 Next(Int32) 依索引隨機選取 choices 專案。 這會用來填入新建立的陣列。

適用於

GetItems<T>(ReadOnlySpan<T>, Span<T>)

來源:
Random.cs
來源:
Random.cs

使用從提供的一組選擇中隨機播放的專案,填入指定範圍的專案。

public:
generic <typename T>
 void GetItems(ReadOnlySpan<T> choices, Span<T> destination);
public void GetItems<T> (ReadOnlySpan<T> choices, Span<T> destination);
member this.GetItems : ReadOnlySpan<'T> * Span<'T> -> unit
Public Sub GetItems(Of T) (choices As ReadOnlySpan(Of T), destination As Span(Of T))

類型參數

T

範圍的類型。

參數

choices
ReadOnlySpan<T>

要用來填入範圍的專案。

destination
Span<T>

要填入專案範圍。

例外狀況

choices 是空的。

備註

方法會使用 Next(Int32) 依索引隨機 choices 選取專案,並填入 destination

適用於

GetItems<T>(T[], Int32)

來源:
Random.cs
來源:
Random.cs

從提供的一組選擇中,建立以隨機播放專案填入的陣列。

public:
generic <typename T>
 cli::array <T> ^ GetItems(cli::array <T> ^ choices, int length);
public T[] GetItems<T> (T[] choices, int length);
member this.GetItems : 'T[] * int -> 'T[]
Public Function GetItems(Of T) (choices As T(), length As Integer) As T()

類型參數

T

陣列的類型。

參數

choices
T[]

要用來填入陣列的專案。

length
Int32

要傳回的陣列長度。

傳回

T[]

填入隨機專案的陣列。

例外狀況

choices 是空的。

choicesnull

length 不是零或正數。

備註

方法會使用 Next(Int32) 依索引隨機選取 choices 專案。 這會用來填入新建立的陣列。

適用於