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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.