Thursday, March 17, 2005

Reference Relevance

As seen in an email list for dotnet programming...

Passing a reference type by value lets the callee manipulate the object that is referenced. Passing a reference type by reference lets the callee manipulate the reference to the object itself - to change where the caller's reference points.
Such are the things one gets to sweat about when the language is not as simple as possible.

Yeah, I know.

And ouch...

One thing to keep in mind when is that the 'ref' is very important when you cross application boundaries. Specifically this applies to .NET Remoting. If a parameter is labeled with 'ref' it will copy the changes back to the caller. This differs significantly from calling a member function locally.