Should/could enums inherit the interfaces of their implemented types? #9403
Replies: 1 comment
-
My bad. This is kind of a duplicate of #8789 and #5093 and probably more |
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
Uh oh!
There was an error while loading. Please reload this page.
-
First of all, for quality of life, this would remove a lot of frustration adding explicit casts when primitive's interface methods with enums.
This would also add real functionality that is currently missing. This would allow additional specification and functionality when using the generic Enum constraint.
Here's my incredibly specific use case from implementing ELF header parsing in C#:
Depending on if the file is 32/64 bit there's a different set of flags. The flags also need to be encoded in either big or little endian (a process which is already incredibly annoying to do with structs, but that's a different issue). This would allow the
IBinaryIntger<T>.TryReadBigEndian
,IBinaryIntger<T>.TryReadLittleEndian
,IBinaryIntger<T>.TryWriteBigEndian
, etc methods to be used on awhere : Enum, IBinaryIntger<T>
constrained generic type.Beta Was this translation helpful? Give feedback.
All reactions