How to add additional generic constraints to a method, rather than adding them to the type? #7646
Answered
by
RikkiGibson
YT-GameMaker
asked this question in
General
-
Should use extensions? |
Beta Was this translation helpful? Give feedback.
Answered by
RikkiGibson
Nov 2, 2023
Replies: 1 comment
-
This is called "generic specialization", and doesn't currently exist in .NET. Extension methods can achieve something similar in some cases, but that requires having an instance receiver. Currently your best bet is probably to write a static Create method which includes all the constraints you want. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
YT-GameMaker
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is called "generic specialization", and doesn't currently exist in .NET. Extension methods can achieve something similar in some cases, but that requires having an instance receiver. Currently your best bet is probably to write a static Create method which includes all the constraints you want.