When you define an enum type, the members contained in your enumeration take on constants starting at zero (for the first member) and then incrementing by one (for consecutive members).
1
2
3
4
5
| public enum Mood { Crabby, // 0 Happy, // 1 Petulant, // 2 Elated }; // 3 |
You can, however, specify the constant value to use for each member. You can specify constants in any order. Members that don’t have a value specified take on a value one greater than the previous member.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| public enum Mood { Crabby = -5, Happy = 5, Petulant = -2, Elated = 10};public enum Weekday{ Sunday = 1, Monday, // 2 Tuesday, // 3, etc. Wednesday, Thursday, Friday, Saturday}; |

