Επεξεργασία

Κοινή χρήση μέσω


Vector.Explicit Operator

Definition

Converts a vector into a Size or a Point.

Overloads

Explicit(Vector to Point)

Creates a Point with the X and Y values of this vector.

Explicit(Vector to Size)

Creates a Size from the offsets of this vector.

Explicit(Vector to Point)

Creates a Point with the X and Y values of this vector.

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

Parameters

vector
Vector

The vector to convert.

Returns

A point with X- and Y-coordinate values equal to the X and Y offset values of vector.

Examples

The following example shows how to convert a Vector into a Point.

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

Applies to

Explicit(Vector to Size)

Creates a Size from the offsets of this vector.

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

Parameters

vector
Vector

The vector to convert.

Returns

A Size with a Width equal to the absolute value of this vector's X property and a Height equal to the absolute value of this vector's Y property.

Examples

The following example shows how to explicitly convert a Vector into a Size.

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

Applies to