How to assign values to an enumeration in C#?
In C#, by default, the members of an enumeration type start with an incrementing integer value of 0. If specific values need to be assigned to enum members, the equals sign (=) can be used for assignment. Below is an example code of assigning values to an enumeration.
enum Direction{
North = 1,
South = 2,
East = 3,
West = 4
}
In the example above, members of the Direction enum type are assigned different integer values. For example, North is assigned a value of 1, South is assigned a value of 2, and so on. If no value is specified for an enum member, they will be assigned values in increments according to the default rules. In the example above, if no value is specified for North, it will default to 0, South will default to 1, and so on.