CMirandaman <CM*********@discussions.microsoft.com> wrote:
Sounds like a stupid question I know. I can tell that they are used to copy
strings. But what is the difference between
x = y;
versus x = String.Copy(y);
Or are they essentially the same?
String.Copy returns a new string with the same content. Assignment uses
the same *reference*.
One potential use of it is to "trim" strings which have been
constructed with StringBuilder. They often have "padding" at the end of
the string (to allow for appending while they're still in
StringBuilder). I've used the equivalent of this in Java a few times -
can't say I've ever used it in .NET.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog:
http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too