Copying elements between arrays : Array Copy « Data Structure « C# / CSharp Tutorial






using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;


public class MainClass
{

    public static void Main()
    {
        int[] srcArray = new int[] { 1, 2, 3 };
        int[] destArray = new int[] { 4, 5, 6, 7, 8, 9 };

        Array.Copy(srcArray, destArray, srcArray.Length);
        srcArray.CopyTo(destArray, 0);
        srcArray.CopyTo(destArray, 3);
        Array.Copy(srcArray, 0, destArray, 2, srcArray.Length);

    }
}








11.12.Array Copy
11.12.1.Copy an array
11.12.2.Copy an array: Copy into middle of target
11.12.3.Copying elements between arrays