C #: pointer to double

I have an ad in the ad too, I want to set the height, this is a pointer to double, but get mesasage errors:

" Error 1 Pointers and fixed size buffers may only be used in an unsafe context",

can someone show me the correct way to declare a pointer type in double?

Below is my declaration, and I set the height of the double pointer (double* height), but receives an error message.

private static extern bool GetElevation(double dLat, double dLon, double* height);
+5
source share
2 answers

Your extern ad should be:

private static extern bool GetElevation(double dLat, double dLon, ref double height);

Hope this helps!

Edit

This question (and the accepted answer) can shed light on the subject. He talks about refvs out(not sure which is better suited to your situation) and Marshalling.

+6
source

, :

  • , #,
  • "", . :

private static unsafe extern bool GetElevation(double dLat, double dLon, double* height)

, /unsafe.

+3

All Articles