How do I overload an operator for an enumeration in C#?

You can’t do that. You can only provide overloaded operators for classes and structs you define — and at least one of the parameters should be of type of the class or struct itself. That is, you can declare an overloaded addition operator that adds a MyClass to MyEnum but you can never do that with two MyEnum values.

Leave a Comment