📜  c# 没有空构造函数的基类 - C# 代码示例

📅  最后修改于: 2022-03-11 14:49:12.160000             🧑  作者: Mango

代码示例1
class A
{
    public A(int x, int y)
    {
        // do something
    }
}

class A2 : A
{
    public A2() : base(1, 5)
    {
        // do something
    }

    public A2(int x, int y) : base(x, y)
    {
        // do something
          // but no need to repeat the statements from the original constructor
    }

    // This would not compile:
    public A2(int x, int y)
    {
        // the compiler will look for a constructor A(), which doesn't exist
    }
}