Exemple #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();
        }
Exemple #2
0
        static void Main()
        {
            DerivedClass instance = new DerivedClass();

            //instance. -- // На экземпляре не видим методов интерфейсов.

            // Приведем экземпляр класса DerivedClass - instance, к базовому интерфейсному типу Interface1

            Interface1 instance1 = instance as Interface1;

            instance1.Method();

            Interface2 instance2 = instance as Interface2;

            instance2.Method();

            // Delay.
            Console.ReadKey();
        }
        static void Main()
        {
            DerivedClass instance = new DerivedClass();

            // instance. - // На екземплярі не бачимо методів інтерфейсів.

            // Приведемо екземпляр класу DerivedClass - instance, до базового багатофункціонального типу Interface1

            Interface1 instance1 = instance as Interface1;

            instance1.Method();

            Interface2 instance2 = instance as Interface2;

            instance2.Method();

            // Delay.
            Console.ReadKey();
        }