Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

copy part of an array into another array [duplicate]

Tags:

arrays

c#

Possible Duplicate:
How to copy part of an array to another array in C#?

if i have:

string[] myArray =  . . . .

which is an array with a length of 10. how can i create a new string array that is the 2nd to 10th elements of the first array without looping?

like image 415
leora Avatar asked May 19 '26 07:05

leora


1 Answers

Use System.Array.Copy:

string[] myArray = ....
string[] copy = new string[10];
Array.Copy(myArray, 2, copy, 0, 10);    
like image 89
codekaizen Avatar answered May 20 '26 21:05

codekaizen