In Classical sense Readonly objects can only be set in the constrcutor and cannot be modified later on. Why do readonly int arrays behave any different.
PS:I am aware of Readonly collections, I am just curious to know why is this allowed ?
class Class1
{
public readonly int[] a;
public Class1()
{
a = new int[3];
a[0] = 1;
a[1] = 2;
a[2] = 3;
}
public void Update()
{
a[0] = 10;
}
}
intarray isn't immutable, just readonly, which means it just can be assigned once (barring some magic tricks like reflection). Its contents, on the other hand, can change...