01 August 2013

How do you explain Passing Parameters by Reference?

One morning, we had a class recitation. There's this shy boy who's good in Math but rarely participate in class recitation. I called him to explain Passing Parameters by Reference. He simply took the whiteboard marker and wrote this on the board:

void X(ref int y) { y*=3};
int z = 4; X(ref z);

Then he told the class, "If the value of z is 12, then you passed the parameters by reference."

No comments:

Post a Comment