Generic Enum helper dud
I hoped I could write a generic helper class that you could use when Refactoring your enum to a class. I wrote this:
class EnhancedEnum<T> where T : struct
{
public readonly T Value;
public EnhancedEnum(T value) { this.Value = value; }
public static implicit operator T(EnhancedEnum<T> e) { return e.Value; }
public static implicit operator EnhancedEnum<T>(T i) { return new EnhancedEnum<T>(i); }
}
But since you can’t make a struct derive from a class, it’s not very useful. Oh, well.
One of the interesting things to note here is the T is no constrained to the builtin integral types, the same way that 'enum' is. That means you could make an enum of any value type. That'd be kinda neat, I think.