Point.Explicit Operator

Definition

Converts a Point into a Size or a Vector.

Overloads

Explicit(Point to Vector)

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)

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)

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.

C#
public static explicit operator System.Windows.Vector(System.Windows.Point point);

Parameters

point
Point

The point to convert.

Returns

A vector with an X value equal to the point's X value and a Y value equal to the point's Y value.

Examples

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

C#
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;
}

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

Explicit(Point to Size)

Creates a Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

C#
public static explicit operator System.Windows.Size(System.Windows.Point point);

Parameters

point
Point

The point to convert.

Returns

A Size structure with a Width equal to this point's X value and a Height equal to this point's Y value.

Examples

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

C#
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;
}

Remarks

Because a Size structure cannot be negative, the absolute values of the point's X and Y properties are used.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10