Software Development Network>> Visual C#>> How to interpret void* in C#?
It's an IntPtr, which is to say, it's a memory address that could point to anything.
If you know that the parameter type should be a pointer to an int, just change the parameter type to ref int instead of IntPtr.
Inside an unsafe block you can get an int * like this
int n = 50;
int * p = &n;
You can pass any pointer in place of a void *, so you could pass &n as your void *.
I don't know. I played with IntPtr and can't see any way to initialise it with the address of a variable without using unsafe code.
How to interpret void* in C#?
kzu
It's an IntPtr, which is to say, it's a memory address that could point to anything.
Rik Dodsworth
hengemd
If you know that the parameter type should be a pointer to an int, just change the parameter type to ref int instead of IntPtr.
CE
Inside an unsafe block you can get an int * like this
int n = 50;
int * p = &n;
You can pass any pointer in place of a void *, so you could pass &n as your void *.
dtwilliamson
I don't know. I played with IntPtr and can't see any way to initialise it with the address of a variable without using unsafe code.
Tracy - MSFT
how could I use IntPtr to point memory of the Int32 value