I suggest you ...

Enums Constraint for Generics

Sometimes I have found my self in the need of doint something like:

where TEnum : Enum

... which currently is not possible.

Workarounds for this do exist, like:

where TEnum : struct, IConvertible

... but it could lead to bugs if not used with care.

Hope a new constraint for enums could make it for .NET 5.

Thanks for reading.

79 votes
Sign in
Password icon
Signed in as (Sign out)
You have left! (?) (thinking…)
Pete shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

Thanks for taking the time to share this suggestion. This item has been around for a couple of versions of Visual Studio and we haven’t acted on it. Looking at the VS “15” plans, we’re not going to take action on this item, so we’re going to close it. If the suggestion is still relevant, please either take a look to see if there’s another suggestion that’s similar that you can vote on, or open a new suggestion.

- The Visual Studio Team


Sign in
Password icon
Signed in as (Sign out)

Feedback and Knowledge Base