Struct Rectangle

Rectangle structure

Stores a set of four integers that represent the location and size of a rectangle.

public struct Rectangle : IEquatable<Rectangle>

Constructors

NameDescription
Rectangle(Point, Size)Initializes a new instance of the Rectangle struct with the specified location and size.
Rectangle(int, int, int, int)Initializes a new instance of the Rectangle structure with the specified location and size.

Properties

NameDescription
Bottom { get; }Gets the y-coordinate that is the sum of the Y and Height property values of this Rectangle structure.
Height { get; set; }Gets or sets the height of this Rectangle structure.
IsEmpty { get; }Gets a value indicating whether all numeric properties of this Rectangle have values of zero.
Left { get; }Gets the x-coordinate of the left edge of this Rectangle structure.
Location { get; set; }Gets or sets the coordinates of the upper-left corner of this Rectangle structure.
Right { get; }Gets the x-coordinate that is the sum of X and Width property values of this Rectangle structure.
Size { get; set; }Gets or sets the size of this Rectangle.
Top { get; }Gets the y-coordinate of the top edge of this Rectangle structure.
Width { get; set; }Gets or sets the width of this Rectangle structure.
X { get; set; }Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure.
Y { get; set; }Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.

Methods

NameDescription
static Ceiling(RectangleF)Converts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.
static FromLTRB(int, int, int, int)Creates a Rectangle structure with the specified edge locations.
static Inflate(Rectangle, int, int)Creates a Rectangle that is inflated by the specified amount.
static Intersect(Rectangle, Rectangle)Returns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.
static Round(RectangleF)Converts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.
static Truncate(RectangleF)Converts the specified RectangleF to a Rectangle by truncating the RectangleF values.
static Union(Rectangle, Rectangle)Gets a Rectangle structure that contains the union of two Rectangle structures.
Contains(Point)Determines if the specified point is contained within this Rectangle structure.
Contains(Rectangle)Determines if the rectangular region represented by rect is entirely contained within the rectangular region represented by this Rectangle.
Contains(int, int)Determines if the specified point is contained within this Rectangle structure.
override Equals(object)Tests whether obj is a Rectangle structure with the same location and size of this Rectangle structure.
Equals(Rectangle)Tests whether other Rectangle structure has the same location and size of this Rectangle structure.
override GetHashCode()Returns the hash code for this Rectangle structure. For information about the use of hash codes, see GetHashCode .
Inflate(Size)Enlarges this Rectangle by the specified amount.
Inflate(int, int)Enlarges this Rectangle by the specified amount.
Intersect(Rectangle)Replaces this Rectangle with the intersection of itself and the specified Rectangle.
IntersectsWith(Rectangle)Determines if this rectangle intersects with rect.
Offset(Point)Adjusts the location of this rectangle by the specified amount.
Offset(int, int)Adjusts the location of this rectangle by the specified amount.
override ToString()Converts the attributes of this Rectangle to a human readable string.
operator ==Tests whether two Rectangle structures have equal location and size.
operator !=Tests whether two Rectangle structures differ in location or size.

Fields

NameDescription
static readonly EmptyRepresents a Rectangle structure with its properties left uninitialized.

See Also