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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...