Copies an array to another array - CSharp System

CSharp examples for System:Array Element

Description

Copies an array to another array

Demo Code



public class Main{
        /// <summary>
        /// Copies an array to another array
        /// </summary>
        /// <param name="original"></param>
        /// <param name="startIndex">The starting index of the array</param>
        /// <returns>An copied array form the start index</returns>
        public static E[] copyArray<E>(E[] original, int startIndex)
        {// w  ww .  java 2  s. c o  m
            E[] returnArray = new E[original.Length - startIndex];
            for (int i = startIndex; i < original.Length; i++)
                returnArray[i - startIndex] = original[i];

            return returnArray;
        }
}

Related Tutorials