GetName for enum with duplicate values

Experimentation shows that:

V1 = “value1”

and

V2 = “value1”

However, this isn’t guaranteed. The MSDN page on Enum.GetName states:

If multiple enumeration members have the same underlying value, the GetName method guarantees that it will return the name of one of those enumeration members. However, it does not guarantee that it will always return the name of the same enumeration member. As a result, when multiple enumeration members have the same value, your application code should never depend on the method returning a particular member’s name.

Leave a Comment