Sar*_*h T 2 c# inheritance constructor
希望是一个简单的问题
我需要序列化一个inherted类,在这个例子中,iProperty继承自'PropertyDescriptor'.为了实现这个,iProperty需要一个参数较少的构造函数,而基类没有这样的构造函数,如果我试图添加一个construtor,我被告知基类不包含一个方法,它接受0个参数是正确的.我该如何解决这个问题.
谢谢.
例
public class iProperty : PropertyDescriptor
{
private string propName;
private object propValue;
// Need Parameterless Construtor ?
public iProperty(string pName, object pValue)
: base(pName, new Attribute[] { })
{
propName = pName;
propValue = pValue;
}
}
Run Code Online (Sandbox Code Playgroud)
public class iProperty : PropertyDescriptor
{
private string propName;
private object propValue;
// Need Parameterless Construtor ?
public iProperty()
: base("placeholder", new Attribute[] { })
{
}
public iProperty(string pName, object pValue)
: base(pName, new Attribute[] { })
{
propName = pName;
propValue = pValue;
}
}
Run Code Online (Sandbox Code Playgroud)