Luka Horvat
Luka Horvat

Reputation: 4402

Fastest way to move a chunk of bytes from one position in a byte array to another within the same array

So the question is pretty straight forward. I have a byte array and I want to move a chunk of those bytes from index i to index i - delta.

Currently I'm using Array.Copy but I'm worried that it might have trouble if the source and destination is the same. Also, Array.Copy deals with any array and since I have this specific type I was wondering if there exists a faster solution.

Upvotes: 4

Views: 2540

Answers (1)

spender
spender

Reputation: 120400

If sourceArray and destinationArray overlap, this method behaves as if the original values of sourceArray were preserved in a temporary location before destinationArray is overwritten.

http://msdn.microsoft.com/en-us/library/z50k9bft.aspx

Upvotes: 4

Related Questions