C#C
C#3y ago
2 replies
gaben

Add attribute to property in base class from derived class when base property already has attribute

I want the derived class's property to have both the added attribute and any that were in the base class:

public abstract class BaseClass
{
    [SomeAttribute]
    public virtual string SomeProperty { get; set; } = "";
}

public class DerivedClass : BaseClass
{
    [SomeOtherAttribute]
    public string SomeProperty { get; set; } = "";
}


DerivedClass -> SomeProperty should have both the SomeAttribute and SomeOtherAttribute attributes
Was this page helpful?