共用方式為


Vector.Addition 運算子

定義

將向量加入至點或另一個向量中。

多載

Addition(Vector, Vector)

將兩個向量相加,並傳回結果做為向量。

Addition(Vector, Point)

依指定的向量平移點,並傳回產生的點。

Addition(Vector, Vector)

將兩個向量相加,並傳回結果做為向量。

public:
 static System::Windows::Vector operator +(System::Windows::Vector vector1, System::Windows::Vector vector2);
public static System.Windows.Vector operator + (System.Windows.Vector vector1, System.Windows.Vector vector2);
static member ( + ) : System.Windows.Vector * System.Windows.Vector -> System.Windows.Vector
Public Shared Operator + (vector1 As Vector, vector2 As Vector) As Vector

參數

vector1
Vector

要相加的第一個向量。

vector2
Vector

要相加的第二個向量。

傳回

Vector

vector1vector2 的總和。

範例

下列範例示範如何使用這個運算子 (+) 來加入兩 VectorVector 結構並傳回 。

private Vector overloadedAdditionOperatorExample1()
{
    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(45, 70);
    Vector vectorResult = new Vector();

    // Add the two vectors together.
    // vectorResult is equal to (65,100)
    vectorResult = vector1 + vector2;

    return vectorResult;
}
Private Function overloadedAdditionOperatorExample1() As Vector
    Dim vector1 As New Vector(20, 30)
    Dim vector2 As New Vector(45, 70)
    Dim vectorResult As New Vector()

    ' Add the two vectors together.
    ' vectorResult is equal to (65,100)
    vectorResult = vector1 + vector2

    Return vectorResult

End Function

另請參閱

適用於

Addition(Vector, Point)

依指定的向量平移點,並傳回產生的點。

public:
 static System::Windows::Point operator +(System::Windows::Vector vector, System::Windows::Point point);
public static System.Windows.Point operator + (System.Windows.Vector vector, System.Windows.Point point);
static member ( + ) : System.Windows.Vector * System.Windows.Point -> System.Windows.Point
Public Shared Operator + (vector As Vector, point As Point) As Point

參數

vector
Vector

用來平移 point 的向量。

point
Point

要平移的點。

傳回

Point

point 轉換 vector 的結果。

範例

下列範例示範如何使用這個運算子 (+) 將結構轉譯 PointVector 結構。

private Point overloadedAdditionOperatorExample2()
{
    Point point1 = new Point(10, 5);
    Vector vector1 = new Vector(20, 30);
    Point pointResult = new Point();

    // Add the point to the vector.
    // pointResult is equal to (30,35).
    pointResult = point1 + vector1;

    return pointResult;
}
Private Function overloadedAdditionOperatorExample2() As Point
    Dim point1 As New Point(10, 5)
    Dim vector1 As New Vector(20, 30)
    Dim pointResult As New Point()

    ' Add the point to the vector.
    ' pointResult is equal to (30,35).
    pointResult = point1 + vector1

    Return pointResult

End Function

另請參閱

適用於