Moving from byte[] to byte[]

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,
 
J

Jay B. Harlow [MVP - Outlook]

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
 
D

Dario

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top