I have the following example for array modification
static void main()
{
int[] arr1 = { 1, 4, 5 };
Console.WriteLine("{0}", arr1[0]);
ModifyArray(arr1);
Console.WriteLine("{0}", arr1[0]);
}
static void ModifyArray(int[] arr1)
{
arr1[0] = 20;
arr1 = new int[5] { -3, -1, -2, -3, -4 };
Console.WriteLine("{0}", arr1[0]);
}
Why it prints
1,-3,20
instead of
1, -3, -3
?