c# - Merging two arrays in .NET -


is there built in function in .net 2.0 take 2 arrays , merge them 1 array?

the arrays both of same type. i'm getting these arrays used function within code base , can't modify function return data in different format.

i'm looking avoid writing own function accomplish if possible.

if can manipulate 1 of arrays, can resize before performing copy:

t[] array1 = getonearray(); t[] array2 = getanotherarray(); int array1originallength = array1.length; array.resize<t>(ref array1, array1originallength + array2.length); array.copy(array2, 0, array1, array1originallength, array2.length); 

otherwise, can make new array

t[] array1 = getonearray(); t[] array2 = getanotherarray(); t[] newarray = new t[array1.length + array2.length]; array.copy(array1, newarray, array1.length); array.copy(array2, 0, newarray, array1.length, array2.length); 

more on available array methods on msdn.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -