Moving from byte[] to byte[]

  • Thread starter Thread starter Tim Conner
  • Start date Start date
T

Tim Conner

Which functions are available to move a part from byte[] into another byte[]
?
Let's say I have a byte[] of 20 and another of 40. And I want to move 5th to
15th from the first byte[] into occupping bytes 20 to 35 of the second
byte[].

Thanks in advance,
 
Tim,
You can use either System.Buffer.BlockCopy or Array.Copy.

I understand that System.Buffer is optimized for primitive types, so it may
perform better than Array.Copy.

Hope this helps
Jay
 
Tim said:
Which functions are available to move a part from byte[] into another byte[]
?
Let's say I have a byte[] of 20 and another of 40. And I want to move 5th to
15th from the first byte[] into occupping bytes 20 to 35 of the second
byte[].


System.Array.Copy is the answer.

E.g.:
Array.Copy(sourceArray, 5, DestinationArray, 20, 16);

- Dario
 
Back
Top