Replies: 2 comments
-
Dupe of #104. |
Beta Was this translation helpful? Give feedback.
0 replies
-
#104 just disappeared, so... Generic constraints make extremely good sense with enum inheritance. Example from the future:
Wait till I show you the example with NT kernel object access flags. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently there's no way to restrict a generic type argument to be an enum. One "workaround" is to restrict the type to a struct perhaps adding IComparable etc to the "where" clause.
So this is a proposal to add this feature to C#.
This was inspired by this related issue:
dotnet/roslyn#18126
This has come up numerous time in certain kinds of designs, it isn't a frequent issue but does arise and does seem like a gap in the language.
Thx
Beta Was this translation helpful? Give feedback.
All reactions