copying a subsection of an array to another array?

J

jeric

I have two byte arrays, X and Y. X contains 100 elements, and Y has 10
elements. I want Y to equal X[50] through X[59]. How can I do this without
a loop? While in this example the arrays are only maxing at 100, in reality
there will be up to 5MB+ stored in this byte array, hence the lack of
wanting to use a loop to do this convertion.

I have seen many builtin convert-to methods take in 3 params: byte[], int
first index, int last index. Then it would convert that subsection to, for
example, a string. Well, I was hoping for a similar method, but for a
byte[] to byte[] convertion, but can not seem to find one. Can someone
point me to the proper method that can do this? Or, is my only option a
hideous loop?

Thanks
-jeric
 
C

Cowboy \(Gregory A. Beamer\)

Array.Copy(ArraytoCopyFrom, IndexFromSource, DestinationArray,
IndexForDestination,
LengthToCopy)

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

**********************************************************************
Think Outside the Box!
**********************************************************************
 

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