The safest thing is to make a copy of the data that it points to.
If you have a byte *, you can, of course, just write the code yourself:
byte* source = whatever;
int size = source[0];
byte[] target = new byte[size];
for (int i = 0; i < size; ++i)
target[i] = source[i+1];
Easy peasy.
If you have IntPtr instead of byte *, you can use this useful method:
http://msdn.microsoft.com/en-us/library/ms146631.aspx
There are many useful methods in the marshal class.
source
share