When are two enums equal in C#?

前端 未结 7 1773
栀梦
栀梦 2020-12-31 22:39

I have created two enums and I know they are not the same but still I think it makes sense they would be equal since their string represent

7条回答
  •  悲&欢浪女
    2020-12-31 23:10

    To be honest, Equality is not straight forward most of the time.

    I would be inclined to create a helper class that implements IEqualityComparer (and any other equality tests, IsSame() for example) and use that.

提交回复
热议问题