January 31, 2009

Pinning Arrays

Example of pinning an array While pinned the array stays locked in memory at its current location
 byte[] bytes = new byte[100];
 bytes[0] = 1;
 bytes[1] = 2;
 bytes[2] = 3;
 bytes[3] = 4;

fixed (byte* pBytes = &bytes[0]) 
{
...
}

No comments: