共用方式為


Vector.LengthSquared 屬性

定義

取得這個向量的長度平方。

public:
 property double LengthSquared { double get(); };
public double LengthSquared { get; }
member this.LengthSquared : double
Public ReadOnly Property LengthSquared As Double

屬性值

這個向量的 Length 平方。

範例

下列範例示範如何使用這個屬性來取得向量長度的平方。

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;
}
Private Function lengthSquaredExample() As Double

    Dim vector1 As New Vector(20, 30)

    ' Gets the square of the length of a Vector. 
    ' lengthSq is equal to 1300.
    Dim lengthSqResult As Double = vector1.LengthSquared

    Return lengthSqResult

End Function

備註

向量的長度有時稱為其大小。

適用於