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

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

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

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