예제 #1
0
        static void Main2(string[] args)
        {
            RectangleBad rc = new RectangleBad(2, 3);

            Console.WriteLine($"{rc} has area {Area(rc)}");

            // should be able to substitute a base type for a subtype
            /*Square*/
            RectangleBad sq = new SquareBad();

            sq.Width = 4;
            Console.WriteLine($"{sq} has area {Area(sq)}");
        }
예제 #2
0
 static public int Area(RectangleBad r) => r.Width * r.Height;