static void Main(string[] args) { ConcreteClass instance = new ConcreteClass(); instance.Method1(); instance.Method2(); IInterface1 instance1 = instance as IInterface1; instance1.Method1(); IInterface2 instance2 = instance as IInterface2; instance2.Method1(); instance2.Method2(); // Delay Console.ReadKey(); }
static void Main(string[] args) { ConcreteClass instance = new ConcreteClass(); instance.Method1(); instance.Method2(); IInterface1 instance1 = instance as IInterface1; instance1.Method1(); IInterface2 instance2 = instance as IInterface2; //тут у нас есть доступ и к Method1 и к Method2 instance2.Method1(); // т.к IInterface2 наследуется от IInterface1 instance2.Method2(); //Delay Console.ReadKey(); }