Point.Explicit 运算符
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
Explicit(Point to Vector) | |
Explicit(Point to Size) |
Explicit(Point to Vector)
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
要变换的点。
返回
一个向量,它的 X 值等于该点的 X 值,且 Y 值等于该点的 Y 值。
示例
下面的示例演示如何显式转换为 Point 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)
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
要变换的点。
返回
一个 Size 结构,它的 Width 等于此点的 X 值,且 Height 等于此点的 Y 值。
示例
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绝对值和Y属性。