How to create duplicate allowed attributes

前端 未结 6 1816
旧巷少年郎
旧巷少年郎 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条回答
  •  难免孤独
    2021-02-02 05:13

    Stick a AttributeUsage attribute onto your Attribute class (yep, that's mouthful) and set AllowMultiple to true:

    [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
    public sealed class MyCustomAttribute: Attribute
    

提交回复
热议问题