I'm bit confused on this.
private void button1_Click(object sender, EventArgs e)
{
int i = 1;
int[] p=new int[4];
p[0] = 25;
method(p);
string o = p[0].ToString();
}
private void method(int[] k)
{
k[0] = 34;
k = null; //##
}
Scene 1 : If i remove k=null
, then my p[0]
turns out as 34
which was modified in 'method' function. Array is reference type so nothing to wonder.
Scene 2 : with k=null
, still my p[0]
returns 34
instead of null
. Why it is so? here i'm making entire array as null but how still first element carries 34
?