Point.Explicit 運算子

定義

Point 轉換為 SizeVectorConverts a Point into a Size or a Vector.

多載

Explicit(Point to Vector)

建立 Vector 結構,其 X 值等於這個點的 X 值且 Y 值等於這個點的 Y 值。Creates a Vector structure with an X value equal to the point's X value and a Y value equal to the point's Y value.

Explicit(Point to Size)

建立 Size 結構,其 Width 等於這個點的 X 值且 Height 等於這個點的 Y 值。Creates a Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

Explicit(Point to Vector)

建立 Vector 結構,其 X 值等於這個點的 X 值且 Y 值等於這個點的 Y 值。Creates a Vector structure with an X value equal to the point's X value and a Y value equal to the point's Y value.

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

參數

point
Point

要轉換的點。The point to convert.

傳回

Vector

向量,其 X 值等於這個點的 X 值且 Y 值等於這個點的 Y 值。A vector with an X value equal to the point's X value and a Y value equal to the point's Y value.

範例

下列範例示範如何明確地將轉換 PointVectorThe following example shows how to explicitly convert a Point into a Vector.

private Vector overloadedExplicitOperatorVectorExample()
{

    Point point1 = new Point(10, 5);

    // Explicitly converts a Point structure into a Vector structure.
    // returnVector is equal to (10,5).
    Vector returnVector = (Vector)point1;

    return returnVector;
}
Private Function overloadedExplicitOperatorVectorExample() As Vector

    Dim point1 As New Point(10, 5)

    ' Explicitly converts a Point structure into a Vector structure.
    ' returnVector is equal to (10,5).
    Dim returnVector As Vector = CType(point1, Vector)

    Return returnVector

End Function

適用於

Explicit(Point to Size)

建立 Size 結構,其 Width 等於這個點的 X 值且 Height 等於這個點的 Y 值。Creates a Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

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

參數

point
Point

要轉換的點。The point to convert.

傳回

Size

Size 結構,其 Width 等於這個點的 X 值且 Height 等於這個點的 Y 值。A Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

範例

下列範例示範如何明確地將轉換 PointSizeThe following example shows how to explicitly convert a Point into a Size.

private Size overloadedExplicitOperatorSizeExample()
{

    Point point1 = new Point(10, 5);

    // Explicitly converts a Point structure into a Size structure.
    // returnSize has a width of 10 and a height of 5  
    Size returnSize = (Size)point1;

    return returnSize;
}
Private Function overloadedExplicitOperatorSizeExample() As Size

    Dim point1 As New Point(10, 5)

    ' Explicitly converts a Point structure into a Size structure.
    ' returnSize has a width of 10 and a height of 5  
    Dim returnSize As Size = CType(point1, Size)

    Return returnSize

End Function

備註

因為 Size 結構不可以是負數,所以 X 會使用點的和屬性的絕對值 YBecause a Size structure cannot be negative, the absolute values of the point's X and Y properties are used.

適用於