In C#, String.Copy() creates another string instance that holds the same characters. In modern .NET it is obsolete, because a normal assignment is usually enough.
You pass one string. It is required. The result is a new string with the same text.
Syntax
Pass the string to copy. Start with this call.
C#
string copy = string.Copy(text);
Call
What it does
string.Copy(text)
Creates another string instance with the same characters.
This is a static method. Prefer a normal assignment unless you have a rare reason to force a separate instance.
Library declarations
C#
public static string Copy(string str);
Parameters
Parameter
Description
str
Required. The string to copy.
Return Value
Return Value
Description
New string
Another instance with the same text.
C# Examples
Example 1 — Basic Copy()
Duplicate a greeting into a new string and confirm the text matches.
C#
using System;
class Program {
static void Main() {
string original = "Hello, C#";
string duplicate = string.Copy(original);
Console.WriteLine($"Original: {original}");
Console.WriteLine($"Duplicate: {duplicate}");
Console.WriteLine($"Same text: {original == duplicate}");
}
}
Output
Original: Hello, C#
Duplicate: Hello, C#
Same text: True
How It Works
Call the static method.string.Copy(original) takes the source string.
Allocate a new string. Characters are copied into a fresh string object.
Compare with ==. Content equality is true—same characters.
Original unchanged. Strings are immutable; original still holds "Hello, C#".
Example 2 — Copy vs Assignment
Assignment reuses a reference; Copy() creates a new object. Text equality stays true either way.