It doesn't change the size of the array. Look at what you are doing.
This initialises a new array with a Length or 2. Creating the array
int[] intArray = new int[] {1,2};
int[0] = 1
int[1] = 2
This line creates a new array of length 3
int[] intArray2 = new int[intArray.Length + 1];
intArray.Length returns 2, then you add 1 to it. Making intArray2 3 in length.
By default all int array values are set to 0 in intArray2.
i.e.
intArray2[0] = 0
intArray2[1] = 0
intArray2[2] = 0
You Copy function is copying the values from intArray to intArray2
making
intArray2[0] = 1
intArray2[1] = 2
intArray2[2] = 0
the line
intArray = intArray2
doesn't copy the values back to intArray. It points intArray to the address of intArray2.
The way your foreach loop is written causes the array to be printed as:
intArray[1] = 2
intArray[2] = 0
intArray[0] = 1
It should be written as
foreach(int i in intArray)
{
Console.Write(i);
}
Update
From my understanding this line of Code
Array.Copy(intArray, intArray2, intArray.Length);
Both copies the elements of intArray into intArray2 and specifies the length of the Destination Array. However, It could also mean that intArray.Length as the last parameter specifies the range of indexes to copy to.
In both these statements you are not quite correct.
The Array.Copy method parameters, in particular the last one you refer to, is the number of elements to copy from the origin array. It won't specify the length of the destination array. Your use of the word range, isn't quite correct either. That would be (IMHO)
Array.Copy(intArray, intArray2, startIndex, endIndex);
which I don't think exists in the .NET Framework.