Vector.LengthSquared Property

Definition

Gets the square of the length of this vector.

C#
public double LengthSquared { get; }

Property Value

The square of the Length of this vector.

Examples

The following example shows how to use this property to get the square of the length of a vector.

C#
private Double lengthSquaredExample()
{

    Vector vector1 = new Vector(20, 30); 

    // Gets the square of the length of a Vector. 
    // lengthSq is equal to 1300.
    Double lengthSqResult = vector1.LengthSquared;

    return lengthSqResult;
}

Remarks

The length of a vector is sometimes referred to as its magnitude.

Applies to

Product Versions
.NET Framework 3.0, 3.5, 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
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10