Point.Explicit 運算子
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
多載
| 名稱 | Description |
|---|---|
| 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 值。
範例
以下範例說明如何明確將 a Point 轉換為 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 性質。