which one has better performance when copy a block of byte?
Asked
Active
Viewed 5,921 times
9
-
What does a profiler output when you test it? – dtb Mar 01 '10 at 05:28
-
@dtb, no i didn't profile it. – Benny Mar 01 '10 at 05:33
2 Answers
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
- 1,026,079
- 266
- 2,566
- 2,900
-
1It's more of a mem-move, in terms of its contract, as it also handles overlapping arrays. – kornman00 Apr 20 '13 at 00:14
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,470
- 7
- 78
- 106