J
Jeff Louie
Steven.. To be clear Clone on a string simply returns a new reference to
the same string.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnguine
t/html/drguinet5_update.asp
When is Clone not Clone?
But what if you want to have two separate strings, each containing the
same value? Well, generally you do not want this. Why waste the memory?
And because strings are immutable, there's not much point in having two
separate strings that have the same value.
So, although String implements IClonable, String.Clone simply returns a
reference to the same string without cloning it.
All is not lost, however: You can use the static method Copy if you
insist on having a second copy of the string.
Regards,
Jeff
the same string.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnguine
t/html/drguinet5_update.asp
When is Clone not Clone?
But what if you want to have two separate strings, each containing the
same value? Well, generally you do not want this. Why waste the memory?
And because strings are immutable, there's not much point in having two
separate strings that have the same value.
So, although String implements IClonable, String.Clone simply returns a
reference to the same string without cloning it.
All is not lost, however: You can use the static method Copy if you
insist on having a second copy of the string.
Regards,
Jeff