小编Ale*_*rte的帖子

如何在基类中声明构造函数,以便子类可以在不声明它们的情况下使用它们?

我希望子类使用其父类的构造函数.但似乎我总是需要在子类中再次定义它们才能使它工作,如下所示:

public SubClass(int x, int y) : base (x, y) {
    //no code here
}
Run Code Online (Sandbox Code Playgroud)

所以我想知道我是不是在父类中正确地声明了构造函数,或者根本没有直接的构造函数继承?

c# inheritance multiple-constructors inherited-constructors

3
推荐指数
1
解决办法
5306
查看次数