-
I have this code:
I get a warning for null value on default. However if I replace K with a valid Enum, I don't get that warning. I was expecting the compiler to infer that since K must be an enum then its default value is 0, it's a value type. What am I missing? |
Beta Was this translation helpful? Give feedback.
Answered by
HaloFour
Apr 10, 2022
Replies: 1 comment 1 reply
-
A weird quirk of the runtime is that |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ebfortin
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A weird quirk of the runtime is that
System.Enum
itself is not a value type and it is also a legal generic type argument to that class. To fix that I suggest also addingstruct
as a generic constraint.