Why the arr[1] value is changing when changing the value of arr1[1]? and similarly why it is changing when ((int[])o)[1] = 1000;
class Program
{
static void Main(string[] args)
{
int[] arr = new int[2];
arr[1] = 10;
Object o = arr;
int[] arr1 = (int[])o;
arr1[1] = 100;
Console.WriteLine(arr[1]);
((int[])o)[1] = 1000;
Console.WriteLine(arr[1]);
}
}
Why the answer is 100 and 1000?
This code is question-5 from https://www.techbeamers.com/csharp-coding-interview-questions-developers/