c# - What AttributeTarget should I use for enum members? -
i want use isgpubasedattribute
enum members this:
public enum effecttype { [isgpubased(true)] pixelshader, [isgpubased(false)] blur }
but compiler doesn't let me use:
[attributeusage (attributetargets.enum, allowmultiple = false)]
what right attributetarget
value limit usage enum members?
far know, there isn't 1 enum constants. closest "field", limits use field members of class or struct (which enum constants treated purposes of attributes).
edit: bringing explanation of "why" comments, enum constants that, , such values , usages embedded directly il. enum declaration therefore not different creating static class definition static constant members:
public static class myenum { public const int value1 = 0; public const int value2 = 1; public const int value3 = 2; public const int value4 = 3; }
... difference being derives system.enum value type instead of being reference class (you can't create static struct, nor unconstructible one).
Comments
Post a Comment