0
Reply

Dereferencing an IntPtr from an array of doubles

David

David

Dec 15 2006 12:34 AM
2.4k
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));