A short note about Buffer.BlockCopy [Gang Peng]

A short note about Buffer.BlockCopy [Gang Peng]

  • Comments 2

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:

http://www.dotnet247.com/247reference/msgs/18/93978.aspx

  • Hmmm...looks like this class was before any FxCop standards were in place...
  • You are talking about the naming. :)
Page 1 of 1 (2 items)