Point Point Point Point Struct

定義

代表在二維空間中的 X 和 Y 座標組。Represents an x- and y-coordinate pair in two-dimensional space.

public value class Point : IFormattable
[System.ComponentModel.TypeConverter(typeof(System.Windows.PointConverter))]
[System.Serializable]
public struct Point : IFormattable
type Point = struct
    interface IFormattable
Public Structure Point
Implements IFormattable
繼承
屬性
實作

範例

下列範例示範如何檢查兩個Point結構是否不相等。The following example shows how to check if two Point structures are not equal. 它也說明如何將值指派給Point結構時所宣告的結構,以及之後已宣告的結構。It also illustrates how to assign values to a Point structure when the structure is being declared and after the structure has been declared.

// Checks if two Points are equal using the overloaded inequality operator.
private Boolean pointInequalityExample()
{
    // Checks if two Points are not equal using the overloaded inequality operator.

    // Declaring point1 and initializing x,y values
    Point point1 = new Point(10, 5);

    // Declaring point2 without initializing x,y values
    Point point2 = new Point();

    // Boolean to hold the result of the comparison
    Boolean areNotEqual;

    // assigning values to point2
    point2.X = 15;
    point2.Y = 40;

    // Compare Point structures for equality.
    // areNotEqual is True
    areNotEqual = (point1 != point2);

    return areNotEqual;

}
' Checks if two Points are equal using the overloaded inequality operator.
Private Function pointInequalityExample() As Boolean
	' Checks if two Points are not equal using the overloaded inequality operator.

	' Declaring point1 and initializing x,y values
	Dim point1 As New Point(10, 5)

	' Declaring point2 without initializing x,y values
	Dim point2 As New Point()

	' Boolean to hold the result of the comparison
	Dim areNotEqual As Boolean

	' assigning values to point2
	point2.X = 15
	point2.Y = 40

	' Compare Point structures for equality.
	' areNotEqual is True
	areNotEqual = (point1 <> point2)

	Return areNotEqual

End Function

備註

在 XAML,之間的分隔符號XY的值Point可以是逗號或空格。In XAML, the delimiter between the X and Y values of a Point can be either a comma or a space.

某些文化特性可以使用逗號字元作為十進位分隔符號,而不是句號字元。Some cultures might use the comma character as the decimal delimiter instead of the period character. XAML 處理而異的文化特性為 EN-US,在大部分的 XAML 處理器實作中,預設值,並預期為小數分隔符號的期間。XAML processing for invariant culture defaults to en-US in most XAML processor implementations, and expects the period to be the decimal delimiter. 您應該避免使用逗號字元作為十進位分隔符號,如果指定Point在 XAML 中,因為會將衝突的字串類型轉換Point屬性值插入XY元件。You should avoid using the comma character as the decimal delimiter if specifying a Point in XAML, because that will clash with the string type conversion of a Point attribute value into the X and Y components.

XAML Attribute UsageXAML Attribute Usage

<object property="x,y"/>  
-or-  
<object property="x y"/>  

XAML 值XAML Values

xx
這個 Point 的 X 座標。The x-coordinate of this Point.

yy
這個 Point 的 Y 座標。The y-coordinate of this Point.

建構函式

Point(Double, Double) Point(Double, Double) Point(Double, Double) Point(Double, Double)

建立新的 Point 結構,包含指定的座標。Creates a new Point structure that contains the specified coordinates.

屬性

X X X X

取得或設定這個 X 結構的 Point 座標。Gets or sets the X-coordinate value of this Point structure.

Y Y Y Y

取得或設定這個 YPoint 座標值。Gets or sets the Y-coordinate value of this Point.

方法

Add(Point, Vector) Add(Point, Vector) Add(Point, Vector) Add(Point, Vector)

Vector 加入至 Point,並傳回結果做為 Point 結構。Adds a Vector to a Point and returns the result as a Point structure.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

判斷指定的 Object 是否為 Point,以及它包含的座標是否與這個 Point 相同。Determines whether the specified Object is a Point and whether it contains the same coordinates as this Point.

Equals(Point) Equals(Point) Equals(Point) Equals(Point)

比較兩個 Point 結構是否相等。Compares two Point structures for equality.

Equals(Point, Point) Equals(Point, Point) Equals(Point, Point) Equals(Point, Point)

比較兩個 Point 結構是否相等。Compares two Point structures for equality.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

傳回這個 Point 的雜湊程式碼。Returns the hash code for this Point.

Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix)

使用指定的 Point 結構轉換指定的 Matrix 結構。Transforms the specified Point structure by the specified Matrix structure.

Offset(Double, Double) Offset(Double, Double) Offset(Double, Double) Offset(Double, Double)

將點的 XY 座標位移指定的數量。Offsets a point's X and Y coordinates by the specified amounts.

Parse(String) Parse(String) Parse(String) Parse(String)

從指定的 Point 建構 StringConstructs a Point from the specified String.

Subtract(Point, Point) Subtract(Point, Point) Subtract(Point, Point) Subtract(Point, Point)

從指定的 Point 減去另一個指定的 Point 並以 Vector 傳回差數。Subtracts the specified Point from another specified Point and returns the difference as a Vector.

Subtract(Point, Vector) Subtract(Point, Vector) Subtract(Point, Vector) Subtract(Point, Vector)

從指定的 Vector 減去指定的 Point 並傳回產生的 PointSubtracts the specified Vector from the specified Point and returns the resulting Point.

ToString() ToString() ToString() ToString()

建立這個 StringPoint 表示。Creates a String representation of this Point.

ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider) ToString(IFormatProvider)

建立這個 StringPoint 表示。Creates a String representation of this Point.

運算子

Addition(Point, Vector) Addition(Point, Vector) Addition(Point, Vector) Addition(Point, Vector)

依指定的 Point 平移指定的 Vector,然後傳回結果。Translates the specified Point by the specified Vector and returns the result.

Equality(Point, Point) Equality(Point, Point) Equality(Point, Point) Equality(Point, Point)

比較兩個 Point 結構是否相等。Compares two Point structures for equality.

Explicit(Point to Vector) Explicit(Point to Vector) Explicit(Point to 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) Explicit(Point to Size) Explicit(Point to Size) 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.

Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point) Inequality(Point, Point)

比較兩個 Point 結構是否相等。Compares two Point structures for inequality.

Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix) Multiply(Point, Matrix)

依指定的 Point 轉換指定的 MatrixTransforms the specified Point by the specified Matrix.

Subtraction(Point, Point) Subtraction(Point, Point) Subtraction(Point, Point) Subtraction(Point, Point)

從指定的 Point 減去另一個指定的 Point 並以 Vector 傳回差數。Subtracts the specified Point from another specified Point and returns the difference as a Vector.

Subtraction(Point, Vector) Subtraction(Point, Vector) Subtraction(Point, Vector) Subtraction(Point, Vector)

從指定的 Vector 減去指定的 Point 並傳回產生的 PointSubtracts the specified Vector from the specified Point and returns the resulting Point.

明確介面實作

IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider) IFormattable.ToString(String, IFormatProvider)

這個成員支援 Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) 基礎結構,但是您不可以從程式碼直接使用它。This member supports the Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) infrastructure and is not intended to be used directly from your code. 如需這個成員的說明,請參閱 ToString(String, IFormatProvider)For a description of this member, see ToString(String, IFormatProvider).

適用於