[RESOLVED] [02/03] assigning a subset of an array in a single stmt
say i have two arrays, array1 and array2
array1 has 20 elements and array2 has 5 elements
i wish to assign array1 elements 0-4 to array2
can i do this in a single statement?
something like this though i don't think syntax is correct for vb:
Re: [02/03] assigning a subset of an array in a single stmt
Try Array.Copy (Array, Array, Int32)
From MSDN
Quote:
Copies a range of elements from an Array starting at the first element and pastes them into another Array starting at the first element. The length is specified as a 32-bit integer.
Supported by the .NET Compact Framework.
Re: [02/03] assigning a subset of an array in a single stmt
Quote:
Originally Posted by kebo
Try Array.Copy (Array, Array, Int32)
From MSDN
Thanks. Exactly what I was looking for. And just to expand a bit in case anyone else looks at this thread. It can take a different number of parameters for more flexiblilty.
Array.Copy(sourceArray, sourceIndex, destinationArray, destinationIndex, length)