Rectangle rect = new Rectangle(10, 20, 100, 50);
if (rect.Contains(x, y)) { // point (x,y) is inside rect }
Graphics g = this.CreateGraphics(); Pen pen = new Pen(Color.Red); g.DrawRectangle(pen, rect);This code creates a graphics object and a pen object with a red color, then uses the DrawRectangle() method to draw the Rectangle object 'rect' onto the graphics object. Overall, the System.Drawing Rectangle class is used for a variety of applications, including drawing shapes, collision detection, and image processing. It is part of the System.Drawing package library, which is included in the .NET Framework Class Library.