C# - Exception while copying the array using foreach loop : Can someone tell me why i'm seeing below exception when i use foreach loop ?

{
6
2 3 4 5 6
Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at W3ResourceArrays.Ex7.Main() in C:\Users\SudhaPraveen\Documents\Visual Studio 2017\Projects\CSharpPractice21DaysPlan\W3ResourceArrays\Ex7.cs:line 28
}

but i don't see this exception if i use for loop. One thing i have noticed is index is starting at 1 if i use foreach loop .

 int[] array1 = new int[] { 1, 2, 3 };
            int[] array2 = new int[] { 4, 5, 6 };

            int[] mergedarray = new int[array1.Length+array2.Length];
            array1.CopyTo(mergedarray, 0);
            array2.CopyTo(mergedarray, array1.Length);
            Console.WriteLine(mergedarray.Length);

            //for (int i = 0; i < mergedarray.Length; i++)
            //{
            //    Console.WriteLine(mergedarray[i]); ;
            //}

            foreach (var item in mergedarray)
            {
                Console.Write(mergedarray[item] + " ");
            }


