title: Reverse way to get double array values from IntPtr
body: <p>Having a double array I can convert it to IntPtr with </p>
  
  <pre><code>public static IntPtr DoubleArrayToIntPtr(double[] d)
  {
      IntPtr p = Marshal.AllocCoTaskMem(sizeof(double) * d.Length);
      Marshal.Copy(d, 0, p, d.Length);
      return p;
  }
  </code></pre>
  
  <p>Now being in an scenario where I can only get array values  from some function "GetPoint" in IntPtr fashion, how can I retrieve double array values from  IntPtr ?</p>
  
  <p>For instance, Suppose <code>path</code> in the following sample is dataset that has (id, x,y,z) structure, holding 5 points coordinates like</p>
  
  <pre><code>(1, 10,10,0)
  (2, 8 ,10,0)
  (3, 9 ,50,0)
  (4, 70,40,0)
  (5, 60,60,0)
  </code></pre>
  
  <p>so I want to get double array values from IntPtr "a" from that function </p>
  
  <p>I was trying like:</p>
  
  <pre><code>for(int i = 0; i &lt; path.GetNumberOfPoints(); i++)  //this does loop five times
  {
      double[] pastPoints = new double[4]; //id,x,y,z
      IntPtr  a = DoubleArrayToIntPtr(pastPoints);
      path.GetPoint(i, a);
      System.Console.WriteLine(pastPoints[0]);
      System.Console.WriteLine(pastPoints[1]);
      System.Console.WriteLine(pastPoints[2]);
      System.Console.WriteLine(pastPoints[3]);
  }
  </code></pre>
  
  <p>but getting only 0's, What am I doing wrong?</p>