-
I have learned latest feature from C# 9 Only because it is pointer ? But it is pointer to managed function it is similar to delegate with one callback ... Is there an answer ? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
It's unsafe because the GC doesn't track the pointer. If you take a pointer to a method in a different assembly and that assembly is later unloaded, nothing invalidates that pointer. It's now just a dangling pointer to undefined and what happens when you call it could be anything from the code working to formatting your hard drive. |
Beta Was this translation helpful? Give feedback.
It's unsafe because the GC doesn't track the pointer. If you take a pointer to a method in a different assembly and that assembly is later unloaded, nothing invalidates that pointer. It's now just a dangling pointer to undefined and what happens when you call it could be anything from the code working to formatting your hard drive.