ImmutableArray.ToImmutableArray Method

Definition

Overloads

ToImmutableArray<T>(ReadOnlySpan<T>)

Produce an immutable array of contents from specified elements.

ToImmutableArray<T>(Span<T>)

Converts the span to an immutable array.

ToImmutableArray<TSource>(IEnumerable<TSource>)

Creates an immutable array from the specified collection.

ToImmutableArray<TSource>(ImmutableArray<TSource>.Builder)

Creates an immutable array from the current contents of the builder's array.

ToImmutableArray<T>(ReadOnlySpan<T>)

Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs

Produce an immutable array of contents from specified elements.

C#
public static System.Collections.Immutable.ImmutableArray<T> ToImmutableArray<T>(this ReadOnlySpan<T> items);

Type Parameters

T

The type of element in the list.

Parameters

items
ReadOnlySpan<T>

The elements to store in the array.

Returns

An immutable array containing the items in the span.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

ToImmutableArray<T>(Span<T>)

Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs

Converts the span to an immutable array.

C#
[System.Runtime.CompilerServices.OverloadResolutionPriority(-1)]
public static System.Collections.Immutable.ImmutableArray<T> ToImmutableArray<T>(this Span<T> items);
C#
public static System.Collections.Immutable.ImmutableArray<T> ToImmutableArray<T>(this Span<T> items);

Type Parameters

T

The type of element in the list.

Parameters

items
Span<T>

The elements to store in the array.

Returns

An immutable array containing the items in the span.

Attributes

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)

ToImmutableArray<TSource>(IEnumerable<TSource>)

Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs

Creates an immutable array from the specified collection.

C#
public static System.Collections.Immutable.ImmutableArray<TSource> ToImmutableArray<TSource>(this System.Collections.Generic.IEnumerable<TSource> items);

Type Parameters

TSource

The type of elements contained in items.

Parameters

items
IEnumerable<TSource>

The collection of objects to copy to the immutable array.

Returns

ImmutableArray<TSource>

An immutable array that contains the specified collection of objects.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)
UWP 10.0

ToImmutableArray<TSource>(ImmutableArray<TSource>.Builder)

Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs
Source:
ImmutableArray.cs

Creates an immutable array from the current contents of the builder's array.

C#
public static System.Collections.Immutable.ImmutableArray<TSource> ToImmutableArray<TSource>(this System.Collections.Immutable.ImmutableArray<TSource>.Builder builder);

Type Parameters

TSource

The type of elements contained in the immutable array.

Parameters

builder
ImmutableArray<TSource>.Builder

The builder to create the immutable array from.

Returns

ImmutableArray<TSource>

An immutable array that contains the current contents of the builder's array.

Applies to

.NET 10 and other versions
Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10
.NET Standard 2.0 (package-provided)