Array subset copying

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

If I have an array..

object[] myObjs = someMethod.SearchForObjs();

and the length of that array is 100, but I want to extract the last 80
objects into another array, what's the cleanest way to do that?
Array.CopyTo seems to allow specification of target index to start copying
into, but not the source array index. Do I need to brute force it and go
with a for loop?

Thanks in advance!

Derrick
 
Derrick the Array.Copy function should work for you.

[C#]
public static void Copy(Array sourceArray, int sourceIndex, Array
destinationArray,
int destinationIndex, int length);
 
Back
Top