Language

Random.GetItems Method

Definition

Overloads

Name Description
GetItems(ReadOnlySpan, Int32)

Creates an array populated with items chosen at random from the provided set of choices.

GetItems(ReadOnlySpan, Span)

Fills the elements of a specified span with items chosen at random from the provided set of choices.

GetItems(T[], Int32)

Creates an array populated with items chosen at random from the provided set of choices.

GetItems(ReadOnlySpan, Int32)

Source:
Random.cs
Source:
Random.cs
Source:
Random.cs
Source:
Random.cs

Creates an array populated with items chosen at random from the provided set of choices.

public:
generic 
 cli::array  ^ GetItems(ReadOnlySpan choices, int length);
public T[] GetItems(ReadOnlySpan 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()

Type Parameters

T

The type of array.

Parameters

choices
ReadOnlySpan

The items to use to populate the array.

length
Int32

The length of array to return.

Returns

T[]

An array populated with random items.

Exceptions

choices is empty.

length is not zero or a positive number.

Remarks

The method uses Next(Int32) to select items randomly from choices by index. This is used to populate a newly-created array.

Applies to

GetItems(ReadOnlySpan, Span)

Source:
Random.cs
Source:
Random.cs
Source:
Random.cs
Source:
Random.cs

Fills the elements of a specified span with items chosen at random from the provided set of choices.

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

Type Parameters

T

The type of span.

Parameters

choices
ReadOnlySpan

The items to use to populate the span.

destination
Span

The span to be filled with items.

Exceptions

choices is empty.

Remarks

The method uses Next(Int32) to select items randomly from choices by index and populate destination.

Applies to

GetItems(T[], Int32)

Source:
Random.cs
Source:
Random.cs
Source:
Random.cs
Source:
Random.cs

Creates an array populated with items chosen at random from the provided set of choices.

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

Type Parameters

T

The type of array.

Parameters

choices
T[]

The items to use to populate the array.

length
Int32

The length of array to return.

Returns

T[]

An array populated with random items.

Exceptions

choices is empty.

choices is null.

length is not zero or a positive number.

Remarks

The method uses Next(Int32) to select items randomly from choices by index. This is used to populate a newly-created array.

Applies to