문제

If I have a class with two base classes :

public partial MyClass : Base1, Base2 {


}

To call the constructor of Base1 I would do this:

public MyClass() : base(myParamForBase1); 

But I need to call the second base class to get the base init value like this:

base.OnInit(e); 

I cannot do the above of course because C# thinks I'm referring to Base1 not Base2, how do I resolve this? In other words how can I refer to Base2?

도움이 되었습니까?

해결책

C# does not support multiple class inheritance. You can only implement multiple interfaces, and inherit from (extend) a single base class.

다른 팁

What you can do is, make a class that inherits from the first base

something like this

    public Base2 : Base1 {


    } 
    public MyClass : Base2  {


    }

Not that i like this, but it may help in some cases

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top