Some bogus examples and statements

  • Thread starter Thread starter Andre
  • Start date Start date
A

Andre

Why is it that most of the articles found on the net (written by
professional authors) and books (such as Sams .NET CLR Unleashed) give
bogus examples and state incorrectly that "reference-types are passed by
reference" in C#? They are *not*. Almost out of 10 articles, 9 make such
a statement. Recently I read an article by Jeffrey Ritcher on Arrays in
..NET, under the Passing and returning Arrays section it states "Arrays
are always passed by reference to a method" as the first line. I thought
Jeffrey would know better? Don't people at MSDN proof read these
articles? Isn't that claim wrong? What's the matter with people!

-Andre
 
In the context of the article and the point JR is trying to make, I think
his statement is fair. At the lowest level, method arguments may be passed
by value, but when you look at it from a higher level of abstraction, the
method does receive a reference to the original array.

True.. but saying 'Arrays are always passed by reference'.. the stress
here is on the phrase 'passing by reference' as we all know.. 'passing
by reference' has a strict and exact meaning in C# and I think it's a
little misleading. I'm sure adding another line saying: All types in C#
are passed by value. Given that a reference type variable holds a
reference to the actual object, in case of arrays (which is a reference
type), a copy of the reference held by the array variable is passed onto
the method (i.e by value) and so method now has a local variable holding
a copy of the reference referring to the actual array on the heap.

I'm sure the above could be further summarized .. my point is... saying
"passed by reference" is incorrect especially when it holds a specific
meaning to the language.

The key point being
that a copy of the array IS NOT made and passed to the method.

Exactly.. you described it to me in a line, so could JR, right? He *did*
write a lenghty article only on Arrays, and I'm sure clarifying a few
lines wouldn't have hurt.
I can assure you that the people at MSDN do proof read articles and if JR
had of said "Arrays are always passed by value to a method...", then
somebody would have been asking questions; yourself included no doubt.

Not really - unless what you stated wouldn't have been further explained
(by a small example perhaps?)
of being a good writer is knowing what to include and what not to include.
In the case of this article, to accurately describe how things really work,
would have required JR to branch off into a side discussion that was out of
context, confusing for the reader, and added little to the article.

Confusing? I disagree. Since I'd read the article only to learn more
about arrays in the first place, I'd love to read a bit more (especially
when it really really matters). One branches off when the discussion at
hand is indirectly or in some way not related to the main topic.

The 9 articles I talked about can be found on websites such as
codeproject.com or other websites that host articles written on C# (I
readlly don't remember - but I can find them for you if you really want
to know).

-Andre
 
Andre,

Couldn't you try to give an example where your attempt for clarification
actually settles an ambiguity or generally solves an issue?


Best regards,

Henrik Dahl
 
Andre,

But is it possible for you to illustrate a situation where you've clarified
something in what you write?


Best regards,

Henrik Dahl
 
Back
Top