CSharp examples for System:Array Element Add
Concatenate various Arrays
using System.Linq; using System.Collections.Generic; using System;// www. j a v a 2s. c om public class Main{ public static T[] Concat_Arrays<T>(params T[][] arrays) { T[] ret = new T[arrays.Sum(_arr => _arr.Length)]; int pos = 0; foreach (var arr in arrays) { Array.Copy(arr, 0, ret, pos, arr.Length); pos += arr.Length; } return ret; } public static void Copy<T>(this T[] array, long sourceIndex, T[] destinationArray, long destinationIndex, long length) { Array.Copy(array, sourceIndex, destinationArray, destinationIndex, length); } public static void Copy<T>(this T[] array, int sourceIndex, T[] destinationArray, int destinationIndex, int length) { Array.Copy(array, sourceIndex, destinationArray, destinationIndex, length); } public static void Copy<T>(this T[] array, T[] destinationArray, long length) { Array.Copy(array, destinationArray, length); } public static void Copy<T>(this T[] array, T[] destinationArray, int length) { Array.Copy(array, destinationArray, length); } public static void Copy<T>(this T[] arr1, bool from_right, T[] arr2, int start1, int start2) { if (from_right) { for (int ii = arr1.Length - 1, jj = arr2.Length - 1; ii >= start1; --ii, --jj) { arr2[jj] = arr1[ii]; } } else { Array.Copy(arr1, start1, arr2, start2, arr1.Length - start1); } } public static T[] Copy<T>(this T[] array) { if (array == null) return null; var ret = new T[array.Length]; array.CopyTo(ret, 0); return ret; } }