Consider the following
public enum E
{
A = 1,
B = 1
}
public string F(E input)
{
return input.ToString();
}
F(E.B); //returns "A"
Now I know that you're not supposed to do ((E)1).ToString(), as it could resolve to A or B (http://msdn.microsoft.com/en-us/library/16c1xs4z.aspx).
But when it's an explicitly chosen value (e.g. B), why does ToString() behave wierdly (returning A)?
When debugging its possible to see that input is B, is it possible to get the selected field in code?
EDIT
This question relates to how the debugger knows which value is passed to F(), whilst in code it doesn't seem possible to detect this?
E.Bfraemwork translate it to the concreate number in your example it is 1. And when it will try to parse/resolve it will look in the enum definitaion to try to find named member for this number and it will select first item. Enum is not a reference type.