Why must the base class be specified before interfaces when declaring a derived class?

后端 未结 7 1754
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 06:54
public interface ITest
{
    int ChildCount { get; set; }
}

public class Test
{
}

public class OrderPool : ITest, Test
{
    public int ChildCount
    {
        ge         


        
7条回答
  •  清酒与你
    2020-12-19 07:35

    it's called syntax

    There are conventions that you must follow in order for the compiler to compile the code.

    They could have chosen to allow both forms, or just the other way around, but they didn't. The reason is probably clarity : you can define a lot of interfaces and only inherit from one class.

    Technically it would have been possible to allow them all in random order, but that would make the code less readable.

提交回复
热议问题