Dereferencing an IntPtr from an array of doubles
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));