Cast Int to Generic Enum in C#

The simplest way I have found is to force the compiler’s hand by adding a cast to object.

return (T)(object)i.Value;

Leave a Comment