I learned that we can get a pointer to an array by GCHandle.AddrOfPinnedObject
, and that the pointer points to the first element of the array.
It is often used to pass an array to C APIs.
But the documentation of the method doesn't mention that it returns a pointer to the first element of an array. The method returns the address of an object as described in the document, but it seems that the method doesn't guarantee that it returns an address of the first element of an array.
So I guess, it depends on the implementation of the Array class. The pointer returned by AddrOfPinnedObject could point to the Length field or something internal data, depending on the implementation. Is it correct?