DeeRain
DeeRain

Reputation: 1354

How do I add an attribute to the field of the base class from child class?

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)]

Upvotes: 4

Views: 2190

Answers (1)

vc 74
vc 74

Reputation: 38179

You'll need to mark the property as virtual in the base class, override it in the child class and add the attributes.

Upvotes: 1

Related Questions