Clone a String in C#

In this article we will discuss about how to create clone a string in c#
  • 3512

The Clone method of string class is used to clone a string. The Clone method returns the reference of the same string. The following code snippet clones a string.


string firstName = "Mahesh";
string lastName = "Chand";
string authorName = firstName + " " + lastName ;
string cloneAuthor = authorName.Clone().ToString();
Console.WriteLine(authorName
);
Console.WriteLine(cloneAuthor
);


 

Ask Your Question 

Got a programming related question? You may want to post your question here
 

Categories

More Articles

© 2018 DotNetHeaven. All rights reserved.