How to create duplicate allowed attributes

前端 未结 6 1797
旧巷少年郎
旧巷少年郎 2021-02-02 04:58

I\'m using a custom attribute inherited from an attribute class. I\'m using it like this:

[MyCustomAttribute(\"CONTROL\")]
[MyCustomAttribute(\"ALT\")]
[MyCustom         


        
6条回答
  •  -上瘾入骨i
    2021-02-02 05:15

    AttributeUsageAttribute ;-p

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    public class MyAttribute : Attribute
    {}
    

    Note, however, that if you are using ComponentModel (TypeDescriptor), it only supports one attribute instance (per attribute type) per member; raw reflection supports any number...

提交回复
热议问题