Sometimes we can splice arrays. The following describes several methods to splice Arrays:
1. Use the CopyTo method of the array:
Int [] array1 = new int [2];
Int [] array2 = new int [5];
Int [] result = new int [array1.Length + array2.Length];
Array1.CopyTo (result, 0 );
Array2.CopyTo (result, array1.Length );
2. Similar to the above method, you can use the static Copy method of the Array class:
Int [] array1 = new int [2];
Int [] array2 = new int [5];
Int [] result = new int [array1.Length + array2.Length];
Array. Copy (array1, 0, result, 0, array1.Length );
Array. Copy (array2, 0, result, array1.Length, array2.Length );
3. You can also splice a list object and convert it to an array.
Int [] array1 = new int [2];
Int [] array2 = new int [5];
List <int> tempList = new List <int> ();
TempList. Addrange (array1 );
TempList. Addrange (array2 );
Result = tempList. ToArray ();