private static void FunWithRectangles () { var r = new Rectangle { TopLeft = new Point {X = 1, Y = 2, Z = 3}, BotRight = new Point {X = 4, Y = 5, Z = 6}, Height = 15, Width = 17 }; Console.WriteLine ("\nRectangle r:\n{0}\n", r.ToString ()); var rClone = (Rectangle) r.Clone (); Console.WriteLine ("\nRectangle rClone:\n{0}\n", rClone.ToString ()); }
private static void ExplicitCasts() { var r = new Rectangle(5, 7); Console.WriteLine(r.ToString()); r.Draw(); Console.WriteLine(); var s = (Square) r; Console.WriteLine(s.ToString()); s.Draw(); Console.WriteLine(); s = (Square) 3; Console.WriteLine(s.ToString()); s.Draw(); Console.WriteLine(); }