Have syntactic sugar for 'class' (+ 'struct') and 'unmanaged' extension methods #2086
Unanswered
john-h-k
asked this question in
Language Ideas
Replies: 1 comment
-
It loses the information that |
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.
-
Restricting extension methods too a base, interface, or struct class can be done simply by (obviously) defining the
this
parameter as the proper base/interface orSystem.ValueType
for structs. It is also possible to constrain extension methods tooclass
andunmanaged
via generics, as such:I suggest that these function signatures below should be equivalent to their generic counterparts
For reference types
For unmanaged types, the same, just with the
unmanaged
keyword.Why?
this [keyword]
rather than a generic type constraint with regex to ignore the name and other parameters etc).struct
, while equal in length / complexity toValueType
signature, is arguably clearerBeta Was this translation helpful? Give feedback.
All reactions