J
Jon Skeet [C# MVP]
Kevin said:I understand what you're saying, Jon. I didn't want to get into a long
discussion of pointers, which many .Net developers are not very familiar
with. Yes, a reference type is passed by value, but it is the value of the
pointer (the address of the class instance), not the class instance, that is
passed, which effectively means that a reference to the class instance is
passed, since the pointer is simply a variable that represents (points to)
the class instance.
While a value type is (technically) referenced by a pointer as well
Not sure what you mean here - the variable itself (assuming one is
involved) is effectively a pointer, but the *value* of that variable is
the actual value, not a pointer.
the value of the instance is copied when it is passed, and the new instance
variable does not point to the same instance as the original.
<snip>
Indeed. I believe we're "on the same page" as it were, but calling the
reference type behaviour "pass by reference" has (justifiably) confused
people in the past. I've always found that explaining that it really
*is* pass-by-value semantics, but that it's a reference which is
passed, helps both those who are new *and* those who understand true
"pass by reference" semantics. It also makes it easier to explain what
happens when you pass a reference type parameter by reference with the
"ref" keyword

Jon