David

David

  • NA
  • 1
  • 0

Dereferencing an IntPtr from an array of doubles

Dec 15 2006 12:34 AM
Hello I am calling an unmanaged library that returns a pointer to an array of doubles. So what I have is an IntPtr doubleArrayPtr. If I want the i'th element in that array, would the correct call be, asuming a 32 bit CPU: IntPtr offsetPtr = doubleArrayPtr.ToInt32() + i * Marshal.Sizeof(typeof(Double)); Double myDouble = (Double)Marshal.PtrToStructure(offsetPtr, typeOf(Double));