when i pass a reference type to a function and update the reference it is reflected in calling function. But when i do same thing for array it is not updated in calling function.
public static void Main()
{
int[] array = new int[10];
Employee emp = new Employee(){Id = 10};
ChangeReference(array, emp);
Console.WriteLine(array.Length); // still print 10
Console.WriteLine(emp.Id) ; // prints updated 100
}
public static void ChangeReference(int[] inputArray, Employee inputEmployee)
{
Employee newEmployee = new Employee(){ID = 100};
int[] newArray = new int[100];
inputEmployee = newEmployee;
inputArray = newArray;
}
6