Compare two objects that contain enum values of the same enum type

Posted by Rire1979 on Stack Overflow See other posts from Stack Overflow or by Rire1979
Published on 2010-05-28T15:06:48Z Indexed on 2010/05/28 15:12 UTC
Read the original article Hit count: 396

Filed under:

I have an enum type defined: EnumType Now imagine

object A = EnumType.Value1;
object B = EnumType.Value2;

I would like to make the comparison ( A == B ) give me the correct result independent of the type of Enum used. In the comparison, the object will always contain enums, and both will be of the same type.

How can I achieve this?

© Stack Overflow or respective owner

Related posts about c#