Example #1
0
    static void Main()
    {
        DerivedClass o = new DerivedClass();

        o.AbstractMethod();
        Console.WriteLine("x = {0}, y = {1}", o.X, o.Y);
    }
Example #2
0
        static void Main()
        {
            var o = new DerivedClass();

            o.AbstractMethod();
            Console.WriteLine($"x = {o.X}, y = {o.Y}");
        }
Example #3
0
            static void Main()
            {
                DerivedClass o = new DerivedClass();                 //注意抽象类是不能实例化的,其派生类是可以实例化的

                o.AbstractMethod();
                Console.WriteLine("x = {0}, y = {1}", o.X, o.Y);
                Console.ReadKey();
            }
Example #4
0
    static void Main()
    {
        // below code is WRONG as Abstract class cannot be instantiated
        // BaseClass b = new BaseClass();
        DerivedClass o = new DerivedClass();

        o.AbstractMethod();
        Console.WriteLine("x = {0}, y = {1}", o.X, o.Y);
    }
        static void Main(string[] args)
        {
            Console.WriteLine("\n11. Differences between an abstract class and an interface         \n------------------------------------");

            // Instantiate using an Abstract class
            DerivedClass o = new DerivedClass();

            o.AbstractMethod();
            Console.WriteLine("- using an abstract class: w = {0}", o.W);

            // Instantiate using an Interface class
            Point pt = new Point(2, 3);

            Console.Write("- using an interface class: Point is " + pt.GetType() + "\n");
            pt.PrintPoint(pt);
        }
 static void Main()
 {
     DerivedClass o = new DerivedClass();
         o.AbstractMethod();
         Console.WriteLine("x = {0}, y = {1}", o.X, o.Y);
 }