A short note about Buffer.BlockCopy [Gang Peng]

Buffer.BlockCopy has following signature:

public static void BlockCopy(Array src,  int srcOffset,  Array dst,  int dstOffset,  int count);


It copies count bytes from src, beginning at srcOffset, to dst, beginning at dstOffset.

srcOffset is the byte offset into src and dstOffset is the byte offset into dst.


Buffer.BlockCopy only supports array of primitive types to keep type safety (MSDN document is not accurate): Boolean, Char, SByte, Byte, Int16, UInt16, Int32, UInt32, Int64, UInt64, Single, Double.

Internally Buffer.BlockCopy just does a memcpy. The interesting fact about this is you can use Buffer.BlockCopy to copy data between arrays of different primitive types:


Comments (2)

  1. Hmmm…looks like this class was before any FxCop standards were in place…

  2. Gang Peng says:

    You are talking about the naming. 🙂

Skip to main content