Skip to content

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

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

You must be logged in to vote
4 replies
@huoyaoyuan

@egvijayanand

@CyrusNajmabadi

@CyrusNajmabadi

You must be logged in to vote
17 replies
@egvijayanand

@huoyaoyuan

@egvijayanand

@huoyaoyuan

Answer selected by CyrusNajmabadi
@CyrusNajmabadi

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