本文整理汇总了C#中Rectangle.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.CompareTo方法的具体用法?C# Rectangle.CompareTo怎么用?C# Rectangle.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.CompareTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main(string[] args)
{
// List<Polygon> polygons = new List<Polygon>();
// polygons.Add(new Polygon());
// polygons.Add(new Rectangle());
// polygons.Add(new Triangle());
// Console.WriteLine(polygons.Count);
// foreach (var p in polygons)
// {
// p.Draw();
// }
// Triangle2 t = new Triangle2();
// t.Draw();
// Polygon2 p = t;
// p.Draw();
Rectangle rect1 = new Rectangle { Length = 10, Width = 20 };
Rectangle rect2 = new Rectangle
{ Length = 100, Width = 200 };
Console.WriteLine(rect1.CompareTo(rect2));
new Widget();
new CompanyBWidget();
}
示例2: Main
static void Main(string[] args)
{
Rectangle r1 = new Rectangle(3, 4);
Console.WriteLine("R1 {0}"+ r1);
Rectangle r2 = new Rectangle(4, 3);
Console.WriteLine("R2 {0}"+ r2);
Rectangle r3 = new Rectangle(1, 4);
Console.WriteLine("R3 {0}"+ r3);
Console.WriteLine();
Rectangle [] rlist = new [] { r1, r2, r3 };
foreach (var x in rlist)
{
Console.WriteLine("List Item: "+ x);
}
Console.WriteLine();
Console.WriteLine("r1 == r3: " + (r1==r3));
Console.WriteLine("r1.Equals(r3): " + r1.Equals(r3));
Console.WriteLine("r1.compareTo(r2): " + r1.CompareTo(r3));
}