c# enum equals() vs ==

If the compile-time type of enumInstance is the enum type, you’re fine with ==.

If the compile-time type of enumInstance is Enum, ValueType or Object, you need to use Equals. (You’ll get a compile-time error if you try to use == in that case.)

Note that your enum currently violates .NET naming conventions – it would normally be MyEnum.Value.

Leave a Comment