Why Can't I stackalloc delegates? #71618
-
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The error message my IDE provides is: "Cannot declare a pointer to a managed type 'Delegate'" |
Beta Was this translation helpful? Give feedback.
-
You can't |
Beta Was this translation helpful? Give feedback.
-
Also you can get function pointer directly from static method if you care about perf. Not array of func pointers tho afaik |
Beta Was this translation helpful? Give feedback.
You can't
stackalloc
for any reference type either.The direct reason is that the result of
stackalloc
IL instruction is a pointer. The span is synthesized by C# compiler.There is already a proposal to enable
stackalloc
for reference type: #11192