Rect Class
Description
The Rect class represents a rectangle with a specified width and height. It provides information about the rectangle's bounds.
Properties
Width: int
: The width of the rectangle.Height: int
: The height of the rectangle.Left: int
: The leftmost coordinate of the rectangle.Right: int
: The rightmost coordinate of the rectangle.Top: int
: The topmost coordinate of the rectangle.Bottom: int
: The bottommost coordinate of the rectangle.
Methods
UpdateBounds(): void
: Updates the bounds of the rectangle based on its width and height.
Usage
To use the Rect class, you can create an instance of it and access its properties. Here's an example:
// Create a new rectangle
Rect rect = new Rect(10, 5);
// Access and modify the rectangle's properties
int width = rect.Width;
int height = rect.Height;
int left = rect.Left;
int right = rect.Right;
int top = rect.Top;
int bottom = rect.Bottom;
// Update the rectangle's bounds
rect.UpdateBounds();