Csharp/C Sharp/2D Graphics/Point — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
(нет различий)
|
Текущая версия на 14:41, 26 мая 2010
Add size to a Point
<source lang="csharp"> using System; using System.Drawing; class Class1 {
[STAThread] static void Main(string[] args) { Point topLeft = new Point(10, 10); Size rectangleSize = new Size(50, 50); Point bottomRight = topLeft + rectangleSize; Console.WriteLine("topLeft = " + topLeft); Console.WriteLine("bottomRight = " + bottomRight); Console.WriteLine("Size = " + rectangleSize); }
}
</source>
Work with Point type
<source lang="csharp"> using System; using System.Drawing;
class Program {
static void Main(string[] args) { // Create and offset a point. Point pt = new Point(100, 72); Console.WriteLine(pt); pt.Offset(20, 20); Console.WriteLine(pt); // Overloaded Point operators. Point pt2 = pt; if (pt == pt2) Console.WriteLine("Points are the same"); else Console.WriteLine("Different points"); // Change pt2"s X value. pt2.X = 4000; // Now show each X: Console.WriteLine("First point: {0}", pt); Console.WriteLine("Second point: {0}", pt2);
}
}
</source>