Vector2.CopyTo Method

Definition

Copies the elements of the vector to an array.

Overloads

CopyTo(Span<Single>)

Copies the vector to the given Span<T>.The length of the destination span must be at least 2.

CopyTo(Single[], Int32)

Copies the elements of the vector to a specified array starting at a specified index position.

CopyTo(Single[])

Copies the elements of the vector to a specified array.

CopyTo(Span<Single>)

Source:
Vector2.cs
Source:
Vector2.cs
Source:
Vector2.cs

Copies the vector to the given Span<T>.The length of the destination span must be at least 2.

public readonly void CopyTo (Span<float> destination);

Parameters

destination
Span<Single>

The destination span into which the values are copied.

Exceptions

The number of elements in the source vector is greater than the number of elements available in destination span.

Applies to

.NET 9 and other versions
Product Versions
.NET 6, 7, 8, 9

CopyTo(Single[], Int32)

Source:
Vector2.cs
Source:
Vector2.cs
Source:
Vector2.cs

Copies the elements of the vector to a specified array starting at a specified index position.

public void CopyTo (float[] array, int index);
public readonly void CopyTo (float[] array, int index);

Parameters

array
Single[]

The destination array.

index
Int32

The index at which to copy the first element of the vector.

Exceptions

array is null.

The number of elements in the current instance is greater than in the array.

index is less than zero.

-or-

index is greater than or equal to the array length.

array is multidimensional.

array is null.

Remarks

array must have a sufficient number of elements to accommodate the two vector elements. In other words, elements index and index + 1 must already exist in array.

Applies to

.NET 9 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
.NET Framework 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1
UWP 10.0

CopyTo(Single[])

Source:
Vector2.cs
Source:
Vector2.cs
Source:
Vector2.cs

Copies the elements of the vector to a specified array.

public void CopyTo (float[] array);
public readonly void CopyTo (float[] array);

Parameters

array
Single[]

The destination array.

Exceptions

array is null.

The number of elements in the current instance is greater than in the array.

array is multidimensional.

array is null.

Remarks

array must have at least two elements. The method copies the vector's elements starting at index 0.

Applies to

.NET 9 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
.NET Framework 4.6, 4.6.1, 4.6.2, 4.7 (package-provided), 4.7, 4.7.1 (package-provided), 4.7.1, 4.7.2 (package-provided), 4.7.2, 4.8 (package-provided), 4.8, 4.8.1
.NET Standard 2.0 (package-provided), 2.1
UWP 10.0