How to get right result of ToString() method in enum with two equal items

后端 未结 4 1739
礼貌的吻别
礼貌的吻别 2021-01-26 00:38

I have enum

[Flags]
public enum MyEnum
{
   Item1 = 32768,
   Item2 = 65536,
   Item3 = 524288,
   Item4 = Item3
}

Results of ToString() operat

4条回答
  •  被撕碎了的回忆
    2021-01-26 00:46

    No, because you set Item4 to be equal to Item3, and as they're just typesafe ints (enums are), the CLR can't tell the difference.

    Try setting Item4 to a different value to get the expected result.

提交回复
热议问题