Hi All
Can someone clarify what is happening in these 2 code fragments ?
int i=0;
Action b = delegate {i++; Console.WriteLi ne("Within b() i= +
i.ToString());} ;
Action<inta = delegate(int j){ j++; Console.WriteLi ne("Within a(i) =
" + j.ToString());} ;
i++;
b();
// i now becomes 2
a(i);
// i is reported as 3 within a
Console.WriteLi ne("i = " + i.ToString());
// i still shows as 2 ****
So the question is why i changes for b and not for a ?
thanks
Sunit
Can someone clarify what is happening in these 2 code fragments ?
int i=0;
Action b = delegate {i++; Console.WriteLi ne("Within b() i= +
i.ToString());} ;
Action<inta = delegate(int j){ j++; Console.WriteLi ne("Within a(i) =
" + j.ToString());} ;
i++;
b();
// i now becomes 2
a(i);
// i is reported as 3 within a
Console.WriteLi ne("i = " + i.ToString());
// i still shows as 2 ****
So the question is why i changes for b and not for a ?
thanks
Sunit
Comment