C# Array Copy() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Array

Definition

In C#, Array.Copy copies elements from a source array into a destination array. You can copy the whole array or a slice by passing starting indexes and a length.

Both arrays must allow the conversion of element types (usually the same type). The destination must be large enough for the range you copy.

This is a static member of System.Array. You call it with the class name, such as Array.Copy(...). Arrays in C# have a fixed length after creation; use List<T> when the count must grow.

Syntax

Call the static Array.Copy method with source, destination, and count (or with index offsets).

C#
Array.Copy(source, dest, source.Length);
Array.Copy(source, 1, dest, 0, 2);
CallWhat it does
Array.Copy(src, dest, 3)Copies 3 elements from index 0 of src to index 0 of dest.
Array.Copy(src, 1, dest, 2, 2)Copies 2 elements starting at src[1] into dest starting at index 2.

For a safer “all or nothing” copy when conversion might fail mid-way, see ConstrainedCopy.

Library declarations
C#
public static void Copy(Array sourceArray, Array destinationArray, int length);
public static void Copy(Array sourceArray, int sourceIndex,
    Array destinationArray, int destinationIndex, int length);

Parameters

ParameterDescription
sourceArrayRequired. The array to read from.
destinationArrayRequired. The array to write into.
sourceIndex / destinationIndexOptional (overload). Starting indexes in each array.
lengthHow many elements to copy.

Return Value

Return ValueDescription
voidNo return value. The destination array is updated in place.

C# Examples

Example 1 — Copy Whole Array Prefix

Copy three ints into a larger destination and print both arrays.

C#
using System;

class Program {
    static void Main() {
        int[] src = { 1, 2, 3 };
        int[] dest = new int[5];

        Array.Copy(src, dest, src.Length);

        Console.WriteLine("src:  " + string.Join(", ", src));
        Console.WriteLine("dest: " + string.Join(", ", dest));
    }
}

How It Works

  1. Count matters. src.Length is 3, so three values move.
  2. Dest keeps size. Dest still has five slots; the last two stay 0.
  3. Src unchanged. Copy reads source; it does not clear it.
  4. Start at zero. This overload begins at index 0 in both arrays.

Example 2 — Copy a Middle Slice

Use indexes to copy only part of the source into a chosen destination offset.

C#
using System;

class Program {
    static void Main() {
        string[] src = { "a", "b", "c", "d" };
        string[] dest = { "-", "-", "-", "-" };

        Array.Copy(src, 1, dest, 0, 2);

        Console.WriteLine(string.Join(", ", dest));
    }
}

How It Works

  1. Source index 1. Copy starts at "b".
  2. Length 2. Only "b" and "c" move.
  3. Dest index 0. They land at the front of dest.
  4. Rest untouched. The last two dashes remain.

Example 3 — Copy Into Equal-Length Target

Make a full duplicate when dest has the same Length.

C#
using System;

class Program {
    static void Main() {
        int[] src = { 9, 8, 7 };
        int[] dest = new int[3];

        Array.Copy(src, dest, 3);
        dest[0] = 100;

        Console.WriteLine("src[0]  = " + src[0]);
        Console.WriteLine("dest[0] = " + dest[0]);
    }
}

How It Works

  1. Independent storage. After Copy, dest is a separate array.
  2. Mutate dest. Changing dest does not alter src.
  3. Full length. Copying 3 into length 3 fills every slot.
  4. Vs Clone. Copy needs a destination you already created; Clone allocates one.

Frequently Asked Questions

It copies a range of elements from a source array into a destination array.
No. The destination must be large enough for the indexes plus length you request.
Clone creates a new array and returns object. Copy writes into an existing destination.
ConstrainedCopy rolls back the destination if copying fails mid-way. Copy may leave a partial update.
Only when the runtime can convert each element. Same-type copies are the common case.

Next: CopyTo()

Copy this array into another array starting at an index with System.Array.

CopyTo() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

13 people found this page helpful