Creates a new instance of string with the same value as a specified instance of string.
- str
- The string to be copied.
A new string with the same value as str.
Type Reason ArgumentNullException str is a null reference.
Documentation for this section has not yet been entered.
The following example demonstrates copying strings.
C# Example
using System; public class StringCopyExample { public static void Main() { string strA = "string"; Console.WriteLine( "The initial string, strA, is '{0}'.", strA ); string strB = String.Copy( strA ); strA = strA.ToUpper(); Console.WriteLine( "The copied string, strB, before strA.ToUpper, is '{0}'.", strB ); Console.WriteLine( "The initial string after StringCopy and ToUpper, is '{0}'.", strA ); Console.WriteLine( "The copied string, strB, after strA.ToUpper, is '{0}'.", strB ); } }The output is
The initial string, strA, is 'string'.
The copied string, strB, before strA.ToUpper, is 'string'.
The initial string after StringCopy and ToUpper, is 'STRING'.
The copied string, strB, after strA.ToUpper, is 'string'.
Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0