Overwrite customattribute on derived class

后端 未结 3 1263
心在旅途
心在旅途 2021-01-08 00:52

We have a custom attribute

[AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
public class CustomDesignerAttribute: Attribute

the

3条回答
  •  臣服心动
    2021-01-08 01:48

    No, it's not possible to override the existing attribute.

    Attributes are metadata attached to an object (assembly, class, method, variable and so on) so they always keep this connection.

    If you want to give a default "behavior" in the base class and override it in some derived classes you have to check all the attributes returned by GetCustomAttributes() to use only the most derived one (the first in the list).

提交回复
热议问题