Jon,
Thanks for the clarification.
Frankly I didn't read the docs on this (I should've). I'd expected this
behavior for interned strings and expected the Clone method to return new
copy for not-interned. However you are right that this implemetation could
make sense to any immutable types, even though the name of the method -
Clone, is little bit confusing in this case.
--
Stoitcho Goutsev (100)
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Stoitcho Goutsev (100) wrote: I suggest reading some information on string interning. If the string is
interned whenever you try to get a reference to the string it will always
return the same reference.
It's not really anything to do with interning. It's arguable that
String.Clone doesn't properly implement ICloneable.Clone, which states
that a reference to a *new* object is returned. However, as has been
pointed out, the documentation for String.Clone itself explains what's
going on.
Any immutable class could implement the same behaviour though, without
having any concept of interning.
Jon