Vector.Explicit 操作员

定义

将向量转换为 SizePoint

重载

Explicit(Vector to Point)

使用此向量的 PointX 值创建 Y

Explicit(Vector to Size)

根据此向量的偏移量创建 Size

Explicit(Vector to Point)

使用此向量的 PointX 值创建 Y

public:
 static explicit operator System::Windows::Point(System::Windows::Vector vector);
public static explicit operator System.Windows.Point (System.Windows.Vector vector);
static member op_Explicit : System.Windows.Vector -> System.Windows.Point
Public Shared Narrowing Operator CType (vector As Vector) As Point

参数

vector
Vector

要变换的向量。

返回

一个点,其 XY 坐标值与 vectorXY 偏移值相等。

示例

以下示例演示如何将 转换为 VectorPoint

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

    // Explicitly converts a Vector structure into a Point structure.
    // returnPoint is equal to (20, 30).
    Point returnPoint = (Point)vector1;

    return returnPoint;
}
Private Function overloadedExplicitOperatorExample2() As Point
    Dim vector1 As New Vector(20, 30)

    ' Explicitly converts a Vector structure into a Point structure.
    ' returnPoint is equal to (20, 30).
    Dim returnPoint As Point = CType(vector1, Point)

    Return returnPoint

End Function

适用于

Explicit(Vector to Size)

根据此向量的偏移量创建 Size

public:
 static explicit operator System::Windows::Size(System::Windows::Vector vector);
public static explicit operator System.Windows.Size (System.Windows.Vector vector);
static member op_Explicit : System.Windows.Vector -> System.Windows.Size
Public Shared Narrowing Operator CType (vector As Vector) As Size

参数

vector
Vector

要变换的向量。

返回

一个 Size,其 Width 等于此向量的 X 属性的绝对值,其 Height 等于此向量的 Y 属性的绝对值。

示例

以下示例演示如何将 显式转换为 VectorSize

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

    // Explicitly converts a Vector structure into a Size structure.
    // returnSize has a width of 20 and a height of 30.
    Size returnSize = (Size)vector1;

    return returnSize;
}
Private Function overloadedExplicitOperatorExample1() As Size
    Dim vector1 As New Vector(20, 30)

    ' Explicitly converts a Vector structure into a Size structure.
    ' returnSize has a width of 20 and a height of 30.
    Dim returnSize As Size = CType(vector1, Size)

    Return returnSize

End Function

适用于