假设我有这个例子:
class A : SomeAbstractClassWithProperties
{
public A(string id, int size)
{
this.Name = "Name1";
this.Something = new SomethingElse(id, size);
}
//...some stuff
}
class B : A
{
public B(string id, int size)
{
this.Name = "Name2";
this.Something = new SomethingElse(id, size);
}
}
好的,这行不通:
Inconsistent accessibility: base class A is less accessible than class 'B'
'A' does not contain a constructor that takes 0 arguments
但正如我们所见,A 类和B类的构造函数几乎相同。只是this.Name不同。我怎么能重写B 类?有什么建议么?谢谢