How to create duplicate allowed attributes

前端 未结 6 1794
旧巷少年郎
旧巷少年郎 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:31

    Anton's solution is correct, but there is another gotcha.

    In short, unless your custom attrbiute overrides TypeId, then accessing it through PropertyDescriptor.GetCustomAttributes() will only return a single instance of your attribute.

提交回复
热议问题