Skip to content

Why are generic Parse methods for Enum types constrained with struct rather than directly with Enum itself? #112776

Discussion options

You must be logged in to vote

It seems Enum generic type implementation is short-circuited, struct constraint with an additional runtime check.

Yes, it was introduced before Enum can be used in constraint, so it can only use struct then.
Changing from struct to the correct struct, Enum constraint is a breaking change.
You can see methods introduced later (GetValues, GetNames) are constrained with struct, Enum. Parse just came too early.

Replies: 2 comments 21 replies

Comment options

You must be logged in to vote
4 replies
@huoyaoyuan
Comment options

@egvijayanand
Comment options

@CyrusNajmabadi
Comment options

@CyrusNajmabadi
Comment options

Comment options

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

@huoyaoyuan
Comment options

@egvijayanand
Comment options

@huoyaoyuan
Comment options

Answer selected by CyrusNajmabadi
@CyrusNajmabadi
Comment options

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