Skip to main content
3 of 4
insert duplicate link

Enum type constraints in C#

Possible Duplicate:
Anyone know a good workaround for the lack of an enum generic constraint?

What is the reason behind C# not allowing type constraints on Enum's? I'm sure there is a method behind the madness, but I'd like to understand why it's not possible.

Below is what I would like to be able to do (in theory).

public static T GetEnum<T>(this string description) where T : Enum { ... } 
Taylor Leese
  • 52.6k
  • 29
  • 115
  • 142