Class Rect
Represents a rectangle defined by its left, top, right, and bottom coordinates.
public class Rect
- Inheritance
-
Rect
- Inherited Members
Constructors
Rect()
Initializes a new instance of the Rect class with default values.
public Rect()
Rect(double, double, double, double)
Initializes a new instance of the Rect class with double coordinates.
public Rect(double left, double top, double right, double bottom)
Parameters
leftdoubleThe left coordinate.
topdoubleThe top coordinate.
rightdoubleThe right coordinate.
bottomdoubleThe bottom coordinate.
Rect(int, int, int, int)
Initializes a new instance of the Rect class with integer coordinates.
public Rect(int left, int top, int right, int bottom)
Parameters
leftintThe left coordinate.
topintThe top coordinate.
rightintThe right coordinate.
bottomintThe bottom coordinate.
Properties
Bottom
Gets or sets the bottom coordinate of the rectangle.
public double Bottom { get; set; }
Property Value
Height
Gets the height of the rectangle.
public double Height { get; }
Property Value
Left
Gets or sets the left coordinate of the rectangle.
public double Left { get; set; }
Property Value
Right
Gets or sets the right coordinate of the rectangle.
public double Right { get; set; }
Property Value
Top
Gets or sets the top coordinate of the rectangle.
public double Top { get; set; }
Property Value
Width
Gets the width of the rectangle.
public double Width { get; }
Property Value
Methods
Equals(object)
Determines whether this rectangle is equal to another object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with.
Returns
- bool
True if the objects are equal; otherwise, false.
GetHashCode()
Returns a hash code for this rectangle.
public override int GetHashCode()
Returns
- int
A hash code based on the rectangle coordinates.
IsEmpty()
Determines whether the rectangle is empty (all coordinates are zero).
public bool IsEmpty()
Returns
- bool
True if all coordinates are zero; otherwise, false.
ToString()
Returns a string representation of this rectangle.
public override string ToString()
Returns
- string
A string in the format "[left,top,right,bottom]".
Operators
operator ==(Rect, Rect)
Determines whether two Rect instances are equal.
public static bool operator ==(Rect left, Rect right)
Parameters
Returns
- bool
True if both rectangles are equal; otherwise, false.
operator !=(Rect, Rect)
Determines whether two Rect instances are not equal.
public static bool operator !=(Rect left, Rect right)
Parameters
Returns
- bool
True if the rectangles are not equal; otherwise, false.