C
C#3w ago
wl32611

I don't understand why function pointer works this way.

In this code, an error occurs when TestMode = 1 or 2 and no error occurs when TestMode = 3. I get the same result whether I use Release Build, Debug Build, or Ctrl+F5. I am using C# 9.
No description
3 Replies
wl32611
wl32611OP3w ago
https://pastebin.com/ftJVPDZt This is source code.
Pastebin
what - Pastebin.com
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
canton7
canton73w ago
I don't know enough to say exactly why this isn't working, but have you seen anything to indicate that it should work? I note that the docs for GetFunctionPointer say:
For instance method handles, the value is not easily usable from user code and is meant exclusively for usage within the runtime.
wasabi
wasabi3w ago
The simple answer is it isn't supported for instance methods. I'm reality the target site for a struct instance method doesn't expect a pointer.

Did you find this page helpful?