Vector(Double, Double) 构造函数

定义

初始化 Vector 结构的新实例。

public:
 Vector(double x, double y);
public Vector (double x, double y);
new System.Windows.Vector : double * double -> System.Windows.Vector
Public Sub New (x As Double, y As Double)

参数

x
Double

XVector 偏移量。

y
Double

YVector 偏移量。

示例

以下示例演示如何创建两个向量并将其一起添加。

private Vector addTwoVectorsExample()
{
    // Create two Vector structures.
    Vector vector1 = new Vector(20, 30);
    Vector vector2 = new Vector(45, 70);
    Vector vectorResult = new Vector();

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

    return vectorResult;
}

适用于