Can you have multiple enum values for the same integer? [duplicate]

In C#, this is allowed, as per the C# Language Specication, version 4. Section 1.10 Enums doesn’t explicitly mention the possibility but, later on in section 14 Enums, 14.3, we see:

Multiple enum members may share the same associated value. The example

enum Color {
   Red,
   Green,
   Blue,
   Max = Blue
}

shows an enum in which two enum members – Blue and Max – have the same associated value.

Leave a Comment