If it’s a byte[]
array:
byte[] managedArray = new byte[size];
Marshal.Copy(pnt, managedArray, 0, size);
If it’s not byte[]
, the size parameter in of Marshal.Copy is the number of elements in the array, not the byte size. So, if you had an int[]
array rather than a byte[]
array, you would have to divide by 4 (bytes per int) to get the correct number of elements to copy, assuming your size parameter passed through the callback refers to the number of bytes.