更新时间:2022-12-08 19:10:00
由于您没有显式调用父构造函数作为子类构造函数的一部分,因此插入了对无参数父构造函数的隐式调用.那个构造函数不存在,所以你会得到那个错误.
Since you don't explicitly invoke a parent constructor as part of your child class constructor, there is an implicit call to a parameterless parent constructor inserted. That constructor does not exist, and so you get that error.
要纠正这种情况,您需要添加一个显式调用:
To correct the situation, you need to add an explicit call:
public Child(int i) : base(i)
{
Console.WriteLine("child");
}
或者,您可以只添加一个无参数的父构造函数:
Or, you can just add a parameterless parent constructor:
protected Parent() { }