示例#1
0
        static void Main()
        {
            DerivedClass instance = new DerivedClass();

            instance.Method();
            instance.Method1();
            instance.Method2();

            Console.WriteLine(new string('-', 40));

            BaseClass instance0 = instance as BaseClass;

            instance0.Method();

            Interface1 instance1 = instance as Interface1;

            instance1.Method1();

            Interface2 instance2 = instance as Interface2;

            instance2.Method2();

            // Delay.
            Console.ReadKey();
        }
        static void Main()
        {
            Interface1 instance1 = new DerivedClass();
            Interface2 instance2 = new DerivedClass();

            instance1.Method1();
            // instance1.Method2();

            instance2.Method2();
            // instance2.Method1();

            // Delay.
            Console.ReadKey();
        }
示例#3
0
        static void Main()
        {
            DerivedClass instance = new DerivedClass();
            instance.Method();
            instance.Method1();
            instance.Method2();

            Console.WriteLine(new string('-', 40));

            BaseClass instance0 = instance as BaseClass;
            instance0.Method();

            Interface1 instance1 = instance as Interface1;
            instance1.Method1();

            Interface2 instance2 = instance as Interface2;
            instance2.Method2();

            // Delay.
            Console.ReadKey();
        }