通过接口的多继承来实现类的多继承   
 interface i2
{
void method2();
}
interface i3
{
void method3();
}
class class2 :i2
{
public void method2()
{
Console.WriteLine("This is the second method in class2");
}
}
class class3 : i3
{
public void method3()
{
Console.WriteLine("This is the third method in class3");
}

我在第3个类class1中继承class2和class3中的method2()和method3()方法,试过几种方法都不行,书上说用接口可以实现类的多继承,但这样写class class1:i2,i3{}
好象也不行

解决方案 »

  1.   

    派生类如果不能实现interface的所有方法,包括重继承。则派生类必须为抽象类。换句话说,
    如果接口派生类,要能创建实体对象,那么类内必须实现接口的所有方法。
      

  2.   

    多继承C# 没有
    实现多接口和多继承,不是一个概念C# 子可以有一个 父类,和0-n个接口
    A->B-> C 这样可以
    -------------
    [A] [B]
     |   |
     -----
       |
      [C]
    ------------
    不行