Enums as type constraints? #5522
-
There are plenty of issues on Stack Overflow regarding how
This does currently not work, but could allow for constructs like the following:
I couldn't think about a lot of other use cases for this, but is this something feasible/desirable to implement? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It would require runtime changes, which basically puts this at -1000 points, rather than the -100 points other changes would require. Which is unfortunate, because the more usable form of this - integer constants - would have lots of potential uses such as matrices or vectors which are implemented in a generic way regardless of the number of elements. |
Beta Was this translation helpful? Give feedback.
-
For those stumbling across this upon their search for a smooth solution for my initial problem, there is a when condition for catch blocks starting from C# 6. |
Beta Was this translation helpful? Give feedback.
It would require runtime changes, which basically puts this at -1000 points, rather than the -100 points other changes would require. Which is unfortunate, because the more usable form of this - integer constants - would have lots of potential uses such as matrices or vectors which are implemented in a generic way regardless of the number of elements.