CollectionExtensions.InsertRange<T> Method

Definition

Inserts the elements of a span into the List<T> at the specified index.

C#
public static void InsertRange<T>(this System.Collections.Generic.List<T> list, int index, ReadOnlySpan<T> source);
C#
public static void InsertRange<T>(this System.Collections.Generic.List<T> list, int index, scoped ReadOnlySpan<T> source);

Type Parameters

T

The type of elements in the list.

Parameters

list
List<T>

The list into which the elements should be inserted.

index
Int32

The zero-based index at which the new elements should be inserted.

source
ReadOnlySpan<T>

The span whose elements should be added to the List<T>.

Exceptions

The list is null.

index is less than 0 or greater than list's Count.

Applies to

Product Versions
.NET 8, 9