I’m just wondering why I get this output :
enum MyEnum
{
a=1,
b=2,
c=3,
d=3,
f=d
}
Console.WriteLine(MyEnum.f.ToString());
OUTPUT
c
But in Mono
OUTPUT
f
So why is the output c? not d? How does the compiler choose c? If I change the code like this:
enum MyEnum
{
a=1,
b=2,
c=3,
d=3,
k=3
}
Console.WriteLine(MyEnum.k.ToString());
OUTPUT
c
again!
Another example:
enum MyEnum
{
a=3,
b=3,
c=3,
d=3,
f=d,
}
MessageBox.Show(MyEnum.f.ToString());
OUTPUT
c
From MSDN:
See: http://msdn.microsoft.com/en-us/library/a0h36syw.aspx#Y300