Skip to content

The enum generic constraint does not function as expected. For nullability analysis, it is not even able to detect it as non-nullable by default. #9166

Answered by 333fred
egvijayanand asked this question in General
Discussion options

You must be logged in to vote

Rather designs should be complete (or near to completion) and not provide workarounds like include struct. When a struct is included, it loses its special meaning.

The design is complete. An enum is nothing more than a struct that inherits from System.Enum. No additional meaning would be provided by allowing you to say where T : enum, it would just be another way of stating the same thing.

Replies: 3 comments 45 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
42 replies
@jnm2
Comment options

jnm2 Feb 22, 2025
Collaborator

@egvijayanand
Comment options

@timcassell
Comment options

@333fred
Comment options

Answer selected by CyrusNajmabadi
@egvijayanand
Comment options

@CyrusNajmabadi
Comment options

@egvijayanand
Comment options

@CyrusNajmabadi
Comment options

Comment options

You must be logged in to vote
3 replies
@egvijayanand
Comment options

@egvijayanand
Comment options

@CyrusNajmabadi
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants