Edit

Share via


ReadOnlyCollection.CreateCollection<T>(ReadOnlySpan<T>) Method

Definition

Creates a new ReadOnlyCollection<T> from the specified span of values.

This method (simplifies collection initialization)[https://free.blessedness.top/dotnet/csharp/language-reference/operators/collection-expressions] to create a new ReadOnlyCollection<T> with the specified values.

public:
generic <typename T>
 static System::Collections::ObjectModel::ReadOnlyCollection<T> ^ CreateCollection(ReadOnlySpan<T> values);
public static System.Collections.ObjectModel.ReadOnlyCollection<T> CreateCollection<T>(scoped ReadOnlySpan<T> values);
static member CreateCollection : ReadOnlySpan<'T> -> System.Collections.ObjectModel.ReadOnlyCollection<'T>
Public Shared Function CreateCollection(Of T) (values As ReadOnlySpan(Of T)) As ReadOnlyCollection(Of T)

Type Parameters

T

The type of elements in the collection.

Parameters

values
ReadOnlySpan<T>

The span of values to include in the collection.

Returns

A new ReadOnlyCollection<T> containing the specified values.

Applies to