I found some old code in which values in an enum were defined with the same numeric value. Now I am wondering about the behavior. A quick test shows:
Console.WriteLine(Test.A.ToString() + Test.B.ToString() + Test.C.ToString() + Test.D.ToString());
enum Test
{
A = 1,
B = 1,
C = 1,
D = 1,
}
// output: BBBB
and
Console.WriteLine(Test.A.ToString() + Test.B.ToString() + Test.C.ToString() + Test.D.ToString());
enum Test
{
A = 1,
C = 1,
B = 1,
D = 1,
}
// output: CCCC
Why do I always get the 2nd name? I would have expected the first or the last one. Is this always the case, or does it depend on some other factors?