is it possible to get an instance of an pointer during runtime? Something like:
Type x = typeof(char*);
How do I get a instance of this pointer? The problem is that I only have a Object with an Type inside. And I know that the Type is a pointer. But now I need a instance of the pointer.
You can:
and back:
But perhaps what you want is something different:
See how for the
TestPointer
, ignoring some problems with non-blittable types, I simply useGCHandle
to obtain a pointer to the value and then pass it directly to the method. No unsafe code necessary :-)For
TestReference
it is much easier: I only need to create the parameters array separately, and then the CLR will put in that array the modified values.