Array.Copy and Buffer.BlockCopy both do the same thing, but BlockCopy is aimed at fast byte-level primitive array copying, whereas Copy is the general-purpose implementation. My question is – under what circumstances should you use BlockCopy? Should you use it at any time when you are copying primitive type arrays, or should you only use it if you’re coding for performance? Is there anything inherently dangerous about using Buffer.BlockCopy over Array.Copy?
Array.Copy and Buffer.BlockCopy both do the same thing, but BlockCopy is aimed at fast
Share
Since the parameters to
Buffer.BlockCopyare byte-based rather than index-based, you’re more likely to screw up your code than if you useArray.Copy, so I would only useBuffer.BlockCopyin a performance-critical section of my code.