共用方式為


Vector.UnaryNegation(Vector) 運算子

定義

將指定的向量變換正負號。

public:
 static System::Windows::Vector operator -(System::Windows::Vector vector);
public static System.Windows.Vector operator - (System.Windows.Vector vector);
static member ( ~- ) : System.Windows.Vector -> System.Windows.Vector
Public Shared Operator - (vector As Vector) As Vector

參數

vector
Vector

要變換正負號的向量。

傳回

XY 值與 vectorXY 值正負號相反的向量。

範例

下列範例示範如何使用這個負運算子來否定 Vector 結構。

private Vector overloadedNegationOperatorExample()
{
    Vector vector1 = new Vector(20, 30);

    // Negate vector1 with the overloaded negation operator.
    // vectorResult is equal to (-20, -30).
    Vector vectorResult = -vector1;

    return vectorResult;
}
Private Function overloadedNegationOperatorExample() As Vector
    Dim vector1 As New Vector(20, 30)

    ' Negate vector1 with the overloaded negation operator.
    ' vectorResult is equal to (-20, -30).
    Dim vectorResult As Vector = -vector1

    Return vectorResult

End Function

適用於

另請參閱