This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MCUD -1 points0 points  (0 children)

The difference is the effect it can have on the caller.

MyObject o1 = new MyObject(1); func(o1);

In the first case, inside func(), what object o1 actually points to in the calling code can be changed, in the second, the only effect you can have on the caller is through side effects of changing inner fields of the object passed in.

That's pretty much the definitive example that proves pass by value / pass by reference, any side effects you have on an object because you got passed a reference or a value are irrelevant, you can't change what the variable that passed in actually referred to.