Possible Duplicate:
Enum type constraints in C#
Could somebody kindly explain to me with a simple sample and simple words why enum
constraints are not allowed on a generic type i.e. What would happen if they were possible?
Possible Duplicate:
Enum type constraints in C#
Could somebody kindly explain to me with a simple sample and simple words why enum
constraints are not allowed on a generic type i.e. What would happen if they were possible?
Simply put: because they're not. That's how the language is designed (you wanted simple, right? :) )
enum
is a value type, so you could put a restraint on your generic type where T : struct
and use Type.IsEnum to check in the constructor, throwing an exception if it returns false.