Прочетете на английски Редактиране

Споделяне чрез


MemoryExtensions.CopyTo Method

Definition

Overloads

CopyTo<T>(T[], Memory<T>)

Copies the contents of the array into a memory region.

CopyTo<T>(T[], Span<T>)

Copies the contents of the array into the span.

CopyTo<T>(T[], Memory<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Copies the contents of the array into a memory region.

C#
public static void CopyTo<T>(this T[]? source, Memory<T> destination);
C#
public static void CopyTo<T>(this T[] source, Memory<T> destination);

Type Parameters

T

The type of the array.

Parameters

source
T[]

The array to copy items from.

destination
Memory<T>

The memory to copy items into.

Exceptions

The destination is shorter than the source array.

Remarks

If source and destination overlap, this method behaves as if the original values are in a temporary location before the destination is overwritten.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1

CopyTo<T>(T[], Span<T>)

Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs
Source:
MemoryExtensions.cs

Copies the contents of the array into the span.

C#
public static void CopyTo<T>(this T[]? source, Span<T> destination);
C#
public static void CopyTo<T>(this T[] source, Span<T> destination);

Type Parameters

T

The type of the array.

Parameters

source
T[]

The array to copy items from.

destination
Span<T>

The span to copy items into.

Exceptions

The destination Span is shorter than the source array.

Remarks

If source and destination overlap, this method behaves as if the original values are in a temporary location before the destination is overwritten.

Applies to

.NET 10 и други версии
Продукт Версии
.NET Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Standard 2.0 (package-provided), 2.1