Exemple #1
0
 static void Main(string[] args)
 {
     // Make a Rectangle.
     Rectangle r = new Rectangle(15, 4);
     Console.WriteLine(r.ToString());
     r.Draw();
     // Convert r into a Square,
     // based on the height of the Rectangle.
     Square s = (Square)r;
     Console.WriteLine(s.ToString());
     s.Draw();
     Console.ReadLine();
     // Implicit cast OK!
     Square s3 = new Square();
     s3.Length = 7;
     Rectangle rect2 = s3;
     Console.WriteLine("rect2 = {0}", rect2);
 }