# Rectangle 結構

## 定義

``public value class Rectangle : IEquatable<System::Drawing::Rectangle>``
``public struct Rectangle : IEquatable<System.Drawing.Rectangle>``
``````[System.ComponentModel.TypeConverter(typeof(System.Drawing.RectangleConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Rectangle : IEquatable<System.Drawing.Rectangle>``````
``type Rectangle = struct``
``````Public Structure Rectangle
Implements IEquatable(Of Rectangle)``````

Rectangle

## 範例

``````Pen blackPen = new Pen(Color.FromArgb(255, 0, 0, 0), 5);
e.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50);
``````
``````Dim blackPen As New Pen(Color.FromArgb(255, 0, 0, 0), 5)
e.Graphics.DrawRectangle(blackPen, 10, 10, 100, 50)
``````

## 建構函式

 使用指定的位置和大小來初始化 Rectangle 類別的新執行個體。Initializes a new instance of the Rectangle class with the specified location and size. 使用指定的位置和大小來初始化 Rectangle 類別的新執行個體。Initializes a new instance of the Rectangle class with the specified location and size.

## 欄位

 代表其屬性未初始化的 Rectangle 結構。Represents a Rectangle structure with its properties left uninitialized.

## 屬性

 取得 Y 座標，其為這個 Y 結構之 Height 和 Rectangle 屬性值的總和。Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure. 取得或設定這個 Rectangle 結構的高度。Gets or sets the height of this Rectangle structure. 測試這個 Rectangle 的所有數值屬性是否具有零值。Tests whether all numeric properties of this Rectangle have values of zero. 取得這個 Rectangle 結構左邊緣的 X 座標。Gets the x-coordinate of the left edge of this Rectangle structure. 取得或設定這個 Rectangle 結構的左上角座標。Gets or sets the coordinates of the upper-left corner of this Rectangle structure. 取得 X 座標，其為這個 X 結構之 Width 和 Rectangle 屬性值的總和。Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure. 取得或設定這個 Rectangle 的大小。Gets or sets the size of this Rectangle. 取得這個 Rectangle 結構上邊緣的 Y 座標。Gets the y-coordinate of the top edge of this Rectangle structure. 取得或設定這個 Rectangle 結構的寬度。Gets or sets the width of this Rectangle structure. 取得或設定這個 Rectangle 結構的左上角 X 座標。Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure. 取得或設定這個 Rectangle 結構的左上角 Y 座標。Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.

## 方法

 藉由將 RectangleF 值捨入為下一個較大的整數值，來將指定的 Rectangle 結構轉換為 RectangleF 結構。Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values. 判斷指定的點是否包含在這個 Rectangle 結構內。Determines if the specified point is contained within this Rectangle structure. 判斷指定的點是否包含在這個 Rectangle 結構內。Determines if the specified point is contained within this Rectangle structure. 判斷由 `rect` 表示的矩形區域是否完全包含在這個 Rectangle 結構中。Determines if the rectangular region represented by `rect` is entirely contained within this Rectangle structure. 測試 `obj` 是否為具有和這個 Rectangle 結構相同位置和大小的 Rectangle 結構。Tests whether `obj` is a Rectangle structure with the same location and size of this Rectangle structure. 使用指定的邊緣位置來建立 Rectangle 結構。Creates a Rectangle structure with the specified edge locations. 傳回這個 Rectangle 結構的雜湊程式碼。Returns the hash code for this Rectangle structure. 如需使用雜湊程式碼的相關資訊，請參閱 GetHashCode()。For information about the use of hash codes, see GetHashCode() . 根據指定的數量來放大這個 Rectangle。Enlarges this Rectangle by the specified amount. 建立並傳回指定之 Rectangle 結構的放大複本。Creates and returns an enlarged copy of the specified Rectangle structure. 複本會以指定的數量來放大。The copy is enlarged by the specified amount. 原始的 Rectangle 結構則維持不修改。The original Rectangle structure remains unmodified. 根據指定的數量來放大這個 Rectangle。Enlarges this Rectangle by the specified amount. 以這個 Rectangle 和指定 Rectangle 的交集，來取代其本身。Replaces this Rectangle with the intersection of itself and the specified Rectangle. 傳回第三個 Rectangle 結構，該結構代表其他兩個 Rectangle 結構的交集。Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. 如果沒有交集，則會傳回空的 Rectangle。If there is no intersection, an empty Rectangle is returned. 判斷這個矩形是否與 `rect` 交集。Determines if this rectangle intersects with `rect`. 以所指定數量來調整這個矩形的位置。Adjusts the location of this rectangle by the specified amount. 以所指定數量來調整這個矩形的位置。Adjusts the location of this rectangle by the specified amount. 藉由將 RectangleF 值捨入為最接近的整數值，來將指定的 Rectangle 轉換為 RectangleF。Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values. 將這個 Rectangle 之屬性轉換為人們可讀取的字串。Converts the attributes of this Rectangle to a human-readable string. 藉由截斷 RectangleF 值，來將指定的 Rectangle 轉換為 RectangleF。Converts the specified RectangleF to a Rectangle by truncating the RectangleF values. 取得 Rectangle 結構，該結構包含兩個 Rectangle 結構的聯集。Gets a Rectangle structure that contains the union of two Rectangle structures.

## 運算子

 測試兩個 Rectangle 結構是否具有相等的位置和大小。Tests whether two Rectangle structures have equal location and size. 測試兩個 Rectangle 結構的位置或大小是否不同。Tests whether two Rectangle structures differ in location or size.