c# multiple inheritance

后端 未结 5 1123
南方客
南方客 2020-12-19 06:35

I would like to achieve this in C#

(Pseudocode)

class A;

class B : A;

class C : A, B;

...

A ac = (A)c;

...

B bc = (B)c;

Is th

5条回答
  •  梦毁少年i
    2020-12-19 06:58

    It is not possible in C#, but, you should also think if this is the scenario you really want.

    Is C really an A and a B ? Or does C has an A and a B. If the latter is true, you should use composition instead of inheritance.

提交回复
热议问题