A shallow copy does not mean "copy only the reference". The definition of
the term (in DotNet at least) is that a copy of the "contents" of the
properties is created. In the case of a reference type the contents is a
reference and as such you end up with two objects pointing to some shared
data. Value types would not exhibit this behavior so you in fact have some
sort of hybrid object.
As to why it is called "Clone" that is because the String class implements
ICloneable. The actual implementation is dependent upon what a class
typically does and Goran Andersson has pointed out very nicely why there is
little need to create another "independent" string in order to create a
clone of a string. By their nature strings are immutable and a clone must
be identical so one copy of the value will suffice. Truth be told string
constants are compiled into the app and anything which needs the sequence
"Process Complete" (for instance) is pointing at the one copy of that string
regardless of how many times it appears in the code.
Tom
" active" <ac**********@a-znet.comwrote in message
news:OJ**************@TK2MSFTNGP05.phx.gbl...
>
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:uI**************@TK2MSFTNGP02.phx.gbl...
>active,
In most cases the Clone creates a "shallow" copy. This means that the
clone, copies only the reference.
In fact does mostly "copy" methods the same.
Could you say the above a little differently - I'm not sure what you mean.