Start New Discussion within our Software Development Community

Hi all,here is the code c# Array.Copy,what does the o means in the code block?
using System;

class Program

Hi all what does the  0 means in the code block?
using System;

class Program
{
    static void Main()
    {
    int[] values1 = { 4, 4, 4 };
    int[] values2 = { 5, 5 };

    int[] all = new int[values1.Length + values2.Length];
    Array.Copy(values1, all, values1.Length);
    Array.Copy(values2, 0, all, values1.Length, values2.Length);

    foreach (int value in all)
    {
        Console.WriteLine(value);
    }
    }

According to the documentation, it's the index in the source array at which copying begins. Presumably the underlying question is why is that overload being used when the source index is 0?

The reason is that values from the source are being appeneded to the destination rather than copying to the destination starting at index 0, which is default behavior for the simpler overloads. Of the four overloads you have, only two of them offer the option to begin copying to the destination at a different index than 0, and both of them require a starting index for the source.

This question has already been answered. Start a new discussion instead.