Attribute inheritance and changing the attribute

If I have a property, method, or event, which has a particular attribute, of a base class, is there any way of changing that attribute in a derived class without creating a re-implementing the property, method, or event. By re-implementing I mean creating a new property, method, or event of the exact same name and signature.

If the property, method, or event, which has a particular attribute, of a base class is virtual, is there any way of changing the attribute in a derived class without overriding the property, method, or event By overriding the property, method, or event

In either case is it possible to add new attributes to the property, method, or event in a derived class without re-implementing the property, method, or event



Answer this question

Attribute inheritance and changing the attribute

  • Tomys

    "No", what isn't Changing the attribute Adding new attributes All cases

  • Constantin Dragomirov

    I know this is an old thread, but I am curious if there is a way to specify that you want to inherit a base classes attributes in your new derived class. I have a base class that have properties that are decorated with several attributes such as DataMember, DataObjectField, DescriptionAttribute that I would like to have inherited in my derived class. I know that if I don't override the property or method, that the attributes do inherit, but if I need to specify additional attributes, such as validation (Enterprise Library), I lose the base attributes on the override.

    Is there any way around this or do I just need to copy the attributes from the base and append them with my validation

    Thanks,

    Jesse


  • JTB1

    eldiener wrote:
    In either case is it possible to add new attributes to the property, method, or event in a derived class without re-implementing the property, method, or event

    No it isn't.



  • that_guy

    No, it isn't possible to add attributes to a base class member from a derived class without overriding that member.



  • Attribute inheritance and changing the attribute