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

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -