SortedSet<T>.CopyTo Method

Definition

Copies a portion or all of a SortedSet<T> to a compatible one-dimensional array, starting at the beginning of the destination array or at a specified index.

Overloads

CopyTo(T[], Int32, Int32)

Copies a specified number of elements from SortedSet<T> to a compatible one-dimensional array, starting at the specified array index.

CopyTo(T[], Int32)

Copies the complete SortedSet<T> to a compatible one-dimensional array, starting at the specified array index.

CopyTo(T[])

Copies the complete SortedSet<T> to a compatible one-dimensional array, starting at the beginning of the target array.

Remarks

This method is an O(n) operation, where n is Count.

CopyTo(T[], Int32, Int32)

Source:
SortedSet.cs
Source:
SortedSet.cs
Source:
SortedSet.cs

Copies a specified number of elements from SortedSet<T> to a compatible one-dimensional array, starting at the specified array index.

C#
public void CopyTo(T[] array, int index, int count);

Parameters

array
T[]

A one-dimensional array that is the destination of the elements copied from the SortedSet<T>. The array must have zero-based indexing.

index
Int32

The zero-based index in array at which copying begins.

count
Int32

The number of elements to copy.

Exceptions

The number of elements in the source array is greater than the available space from index to the end of the destination array.

array is null.

index is less than zero.

-or-

count is less than zero.

Remarks

This method is an O(n) operation, where n is count.

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, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

CopyTo(T[], Int32)

Source:
SortedSet.cs
Source:
SortedSet.cs
Source:
SortedSet.cs

Copies the complete SortedSet<T> to a compatible one-dimensional array, starting at the specified array index.

C#
public void CopyTo(T[] array, int index);

Parameters

array
T[]

A one-dimensional array that is the destination of the elements copied from the SortedSet<T>. The array must have zero-based indexing.

index
Int32

The zero-based index in array at which copying begins.

Implements

Exceptions

The number of elements in the source array is greater than the available space from index to the end of the destination array.

array is null.

index is less than zero.

Remarks

This method is an O(n) operation, where n is Count.

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, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

CopyTo(T[])

Source:
SortedSet.cs
Source:
SortedSet.cs
Source:
SortedSet.cs

Copies the complete SortedSet<T> to a compatible one-dimensional array, starting at the beginning of the target array.

C#
public void CopyTo(T[] array);

Parameters

array
T[]

A one-dimensional array that is the destination of the elements copied from the SortedSet<T>.

Exceptions

The number of elements in the source SortedSet<T> exceeds the number of elements that the destination array can contain.

array is null.

Remarks

The indexing of array must be zero-based.

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, 9, 10
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0