Create multiple attributes?
An ATM machine can't imagine how this would work. I'm sure it can be done. I notice the use of template in my attribute, where I always use 3 specific attributes together. Take below as an example
[MyAttr(4, @"a"),
MyAttr(41, "b"),
MyAttr(45, "ab")]
Mine is much more complex, but I would like to define one attribute with more parameters to generate the data above. How can i do this? Let's say my one attribute would look like this
MyAttr2(4, 41, "a", "b"); //4+41=45, "a"+"b" = "ab"
How can I generate 3 MyAttr to apply to a class using MyAttr2?
The C # compiler cannot convert a single attribute entry to multiple in assembly metadata. However, you can model your attribute in such a way that it provides additional information about the attributes as properties (or collection). However, child information will not be directly accessible through reflection as independent attributes.
source to share