我有一个基类:
public class Base {
public string Foo { get; set; }
public float Bar { get; set; }
public float Foobar { get; set; }
public Base (string foo, float bar, float foobar) {
Foo = foo;
Bar = bar;
Foobar = foobar;
}
}
Run Code Online (Sandbox Code Playgroud)
当我尝试添加扩展此类的类时,我收到错误:
public class Derived : Base {
public Base derived = new Derived ("Foo", 0f, 0f);
}
Run Code Online (Sandbox Code Playgroud)
收到的错误说明如下: Base does not contain a constructor that takes 0 arguments
我在Derived类的第1行得到了这个错误.任何修复/原因导致这种情况发生?