# Rectangle 结构

## 定义

public value class Rectangle : IEquatable<System::Drawing::Rectangle>
public value class Rectangle
public struct Rectangle : IEquatable<System.Drawing.Rectangle>
public struct Rectangle
[System.ComponentModel.TypeConverter(typeof(System.Drawing.RectangleConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public struct Rectangle
type Rectangle = struct
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.RectangleConverter))>]
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type Rectangle = struct
Public Structure Rectangle
Implements IEquatable(Of Rectangle)
Public Structure 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 坐标，该坐标是此 Rectangle 结构的 Y 与 Height 属性值之和。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 坐标，该坐标是此 Rectangle 结构的 X与 Width 属性值之和。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. 指示当前对象是否等于同一类型的另一个对象。Indicates whether the current object is equal to another object of the same type. 创建一个具有指定边缘位置的 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 舍入到最近的整数值，将指定的 RectangleF 转换为 Rectangle。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 值，将指定的 RectangleF 转换为 Rectangle。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.