The C# Copy function is employed to generate a fresh String instance containing the identical value as a designated String. This method is a static member of the String class and returns a string data type.
Signature
Example
public static string Copy(String str)
Parameter
The str function requires a string parameter to duplicate a given string.
Return
It returns string object.
C# String Copy Method Example
Example
using System;
public class StringExample
{
public static void Main(string[] args)
{
string s1 = "Hello ";
string s2 = string.Copy(s1);
Console.WriteLine(s1);
Console.WriteLine(s2);
}
}
Output:
Output
Hello
Hello