Rectangle myRectangle = new Rectangle(0, 0, 100, 100); Point myPoint = new Point(50, 50); if (myRectangle.Contains(myPoint)) { Console.WriteLine("The point is inside the rectangle."); } else { Console.WriteLine("The point is outside the rectangle."); }
Rectangle rect1 = new Rectangle(0, 0, 100, 100); Rectangle rect2 = new Rectangle(25, 25, 50, 50); if (rect1.Contains(rect2)) { Console.WriteLine("The second rectangle is completely inside the first rectangle."); } else { Console.WriteLine("The second rectangle is not completely inside the first rectangle."); }Both examples use the Microsoft.Xna.Framework package library.