Enum type constraints in C#

Posted by Taylor L on Stack Overflow See other posts from Stack Overflow or by Taylor L
Published on 2009-08-26T00:26:58Z Indexed on 2010/05/10 17:04 UTC
Read the original article Hit count: 333

Filed under:
|
|
|

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
{
...
}

© Stack Overflow or respective owner

Related posts about c#

Related posts about .NET