9

which one has better performance when copy a block of byte?

Benny
  • 8,277
  • 7
  • 58
  • 91

2 Answers2

10

Buffer.BlockCopy is pretty optimised - it is basically a wrapper over a raw mem-copy; so it should be pretty fast (and avoids messing with pointers and unsafe code). It should be the default. You could of course measure it each way...

Marc Gravell
  • 976,458
  • 251
  • 2,474
  • 2,830
4

Handling of Large Byte Arrays at http://www.codeproject.com/KB/dotnet/Large_Byte_Array_handling.aspx documents performance versus various methods, include the methods in your question.

AMissico
  • 21,219
  • 6
  • 74
  • 106