Vector2 Constructors

Definition

Creates a new Vector2 object.

Overloads

Vector2(ReadOnlySpan<Single>)

Constructs a vector from the given ReadOnlySpan<T>. The span must contain at least two elements.

Vector2(Single)

Creates a new Vector2 object whose two elements have the same value.

Vector2(Single, Single)

Creates a vector whose elements have the specified values.

Vector2(ReadOnlySpan<Single>)

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

Constructs a vector from the given ReadOnlySpan<T>. The span must contain at least two elements.

C#
public Vector2(ReadOnlySpan<float> values);

Parameters

values
ReadOnlySpan<Single>

The span of elements to assign to the vector.

Applies to

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

Vector2(Single)

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

Creates a new Vector2 object whose two elements have the same value.

C#
public Vector2(float value);

Parameters

value
Single

The value to assign to both elements.

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

Vector2(Single, Single)

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

Creates a vector whose elements have the specified values.

C#
public Vector2(float x, float y);

Parameters

x
Single

The value to assign to the X field.

y
Single

The value to assign to the Y field.

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