Rectangle contains a point : Rectangle : Drawing 2D C# Examples


C# Examples » Drawing 2D » Rectangle »

 

Rectangle contains a point









    
using  System;
using  System.Drawing;

class  MainClass
{
    public  static  int  Main(string[]  args)
    {
        Rectangle  r1  =  new  Rectangle(0,  0,  100,  100);
        Point  pt3  =  new  Point(101,  101);

        if(r1.Contains(pt3))
            Console.WriteLine("Point  is  within  the  rect!");
        else
            Console.WriteLine("Point  is  not  within  the  rect!");
    
        return  0;
    }
}
    
   
  
   



Output

Point is not within the rect!


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Drawing 2D
» Rectangle