c# - String.Clone() what is it's purpose? -


this question has answer here:

from string.clone() on msdn:

the return value not independent copy of instance; view of same data. use copy or copyto method create separate string object same value instance.

because clone method returns existing string instance, there little reason call directly.

it understanding string reference type meaning ever reference string object when calling string.

therefore why string.clone() exist? it's purpose?

this useful since string implements icloneable, can create copy of clones collection of icloneable items. boring when collection of strings only, it's useful when collection contains multiple types implement icloneable. copying single string has no use, since returns design reference itself.

refer : what's use of string.clone()?

the clone() method returns reference string being cloned. not independent copy of string on heap. reference on same string.

and read article : explanation clone examples


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -