问题
Base class:
public class XmlNameValueField : XmlBaseField
{
[XmlAttribute("n")]
[Required]
public string Name { get; set; }
[XmlText]
public string Value { get; set; }
}
Child Class:
public class DateField : XmlNameValueField
{
}
In the Child class field Name must have an additional attribute
[DataType (DataType.EmailAddress)]
回答1:
You'll need to mark the property as virtual in the base class, override it in the child class and add the attributes.
来源:https://stackoverflow.com/questions/7851069/how-do-i-add-an-attribute-to-the-field-of-the-base-class-from-child-class