Csharp/C Sharp by API/System.Drawing/Rectangle — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 12:11, 26 мая 2010
new Rectangle(int x, int y, int width, int height)
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;
}
}
Rectangle.Contains
using System;
using System.Drawing;
class Program {
static void 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!");
// Now place point in rectangle"s area.
pt3.X = 50;
pt3.Y = 30;
if (r1.Contains(pt3))
Console.WriteLine("Point is within the rect!");
else
Console.WriteLine("Point is not within the rect!");
}
}