This does not work enums . Enumeration allows you to specify a specific value so that you can more intelligently refer to it in your code.
If you want to limit the scope, enums may not be the right choice. An alternative is to simply create a set of valid values ββthat can be used as a gain:
private int[] ValidGainValues = new []{ 1, 2, 4, 8};
If you want to make it more typical, you can even create your own type using a private constructor, define all valid values ββas static, public instances, and then expose them that way. But you still have to give each correct value a name - because in the names of members / variables, C # cannot start with a number (although they can contain them).
Now, if you really want to, you need to assign specific values ββto the entries in the GainValues ββenum , which you CAN:
private enum GainValues { One = 1, Two = 2, Four = 4, Eight = 8 };
LBushkin Jun 01 '10 at 18:21 2010-06-01 18:21
source share