String.Copy(String) Method is used to create a new instance of String with the same value as a specified String. In other words, this method is used to copy the data of one string into a new string.
The new string contains same data like an original string but represents a different object reference.
public static string Copy (string value);
Parameter: Here value is the string which is to be copied.
Return Value: The return type of this method is System.String. This method returns a new string that contains the data similar to the value.
Exception: This method will give ArgumentNullException if the value is null.
Below given are some examples to understand the implementation in a better way:
Original String strA: GeeksforGeeks Copied String strB: GeeksforGeeks
Original string A: GeeksforGeeks Original string B: C# Tutorials After copy: Value of string A: GeeksforGeeks Value of string B: GeeksforGeeks Is reference of strings is equal : False
- C# | Copy the elements of a string array to the end of the StringCollection
- C# | Equals(String, String) Method
- Shallow Copy and Deep Copy in C#
- C# | String
- C# | String Operators
- C# | String class
- C# | Add a string to the end of the StringCollection
- C# | String.Contains() Method
- C# | String vs StringBuilder
- C# | String Properties
- C# | How to get the HashCode for the string
- C# | Check if the specified string is in the StringCollection
- C# | Uri.CheckSchemeName(String) Method
- C# | Uri.CheckHostName(String) Method
- C# | How to get TypeCode for the class String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.