Using an enum having entries with the same value of underlying type

后端 未结 3 865
遇见更好的自我
遇见更好的自我 2021-01-16 17:28

if i declare an enum like

enum Weekdays
{
    Mon = 1,
    Tue = 1,
    Wen = 1,
    Thi,
    Fri,
    Sat,
    Sun
}

Weekdays obj = (Weekdays)1;
Console.Wr         


        
3条回答
  •  误落风尘
    2021-01-16 18:33

    As Per MSDN If multiple enumeration members have the same underlying value and you attempt to retrieve the string representation of an enumeration member's name based on its underlying value, your code should not make any assumptions about which name the method will return.

提交回复
热议问题