Now that we have enum constraint, why doesn\'t compiler allow me to write this code?
public static TResult? ToEnum(this String value, TResult?
You can, but you have to add another constraint: the struct constraint.
struct
public static void DoSomething(T? defaultValue) where T : struct, Enum { }