Tuesday, 28 February 2017

Generic C# method taking where the enum value as a parameter


Possible Duplicate:
Create Generic method constraining T to an Enum







Given a generic method that only operates on enum values



static void  method(T enum) where T ?????
{
// do something with enum...
}



How do I constrain T such that only enum values are accepted? I've tried using struct however this disallows the use calling my method with a nullable enum type.

No comments:

Post a Comment