merge two arrays
Published: 30. January 2012 | Updated: 30. January 2012License: Microsoft Public License (MS-PL)
Categories: Framework » Arrays
Tags: Array C#
Method
public static T[] MergeArrays<T>(T[] first, T[] second) { T[] result = new T[first.Length + second.Length]; Array.Copy(first, result, first.Length); Array.Copy(second, 0, result, first.Length, second.Length); return result; }
Use
int[] a = new int[] { 1, 2, 3, 4, 5 }; int[] b = new int[] { 6, 7, 8, 9, 10 }; int[] c = MergeArrays(a, b);
| Send us feedback about this snippet » |





