int x = 2 , y = 4 , z = 1 ;
y = cal ( ref z , ref x , y); .....caling Cal(ref 1, ref 2, 4)
int cal (ref int x , ref int y , int z) ......(ref 1,ref 2, 4)
{
x = x + z + 2; .......x = 1 + 4 + 2; now x is 7 which reference Z
y = x + z + 3;........y= 7 + 4 + 3; now y is 14 which refers X
z=y;......................z is 14 wich ref y;
return x;....... return 7
}
y = cal ( ref z , ref x , y); ....assign returned value to y which is 7
I change the function paramaters this way:-
int x = 2 , y = 4 , z = 1 ;
y = cal( ref z , ref x , y);
int cal(ref int z, ref int x, int y)
{
z = z + y + 2;
x = z + y + 3;
y = x;
return z;
}
The result are:
X=14
Y=7
Z=7