if a property accepts value of type int which is a readonly property then modifying the original private values is not possible from another class
for example:
class cl1
{
private int _num;
public int Num
{
get
{
return _num;
}
}
public cl1()
{
_num=10;
}
}
here if i try to modify _num variable from Num property
example:
cl1 c = new cl1();
c.Num=10;
this is not possible since the Num property of the cl1 class is a readonly property
whereas instead this if i have an int array
for example like this:
class cl1
{
private int[] _num;
public int[] Num
{
get
{
return _num;
}
}
public cl()
{
_num=new int{1,2,3,4};
}
}
class cl2
{
static void main()
{
cl1 c = new cl1();
c.Num[0]=30;
int[] val= c.Num;
foreach(int x in val)
{
}
}
}
the output is now 30 2 3 4 instead of 1 2 3 4 even when the property Num in class cl1 is not allowed to make modification in the original private int[] arr _num
or does not has a "set" accessor in the Num propery.
how the modification in the original int[] array _num becomes possible.think iv'e hardly understood the concept,also i'm pretty confused with what's happening behind the scenes.