C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
C# String Clone()The C# Clone() method is used to clone a string object. It returns another copy of same data. The return type of Clone() method is object. Signaturepublic object Clone() ParametersIt does not take any parameter. ReturnsIt returns a reference. C# String Clone () method example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello ";
string s2 = (String)s1.Clone();
Console.WriteLine(s1);
Console.WriteLine(s2);
}
}
Output: Hello Hello
Next TopicC# String Compare()
|