C# String CopyTo() Method Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report In C#, the CopyTo() is a method of String Class. It is used to copy a specified number of characters from a specified position in the string and it copies the characters of this string into an array of Unicode characters.Example 1: Using the CopyTo() method to copy characters from a string to a character array. C# // C# program to illustrate the // String.CopyTo() Method // Method using System; class Geeks { public static void Main() { // Creating a string string s = "GeeksForGeeks"; // Destination char array char[] dest = new char[3]; //Copying 3 characters from the 5th index //of the string to the destination char array. s.CopyTo(5, dest, 0, 3); // Displaying the copied string Console.WriteLine($"The Copied String is: {new string(dest)}"); } } OutputThe Copied String is: For Syntax of String CopyTo() Methodpublic void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count)Parameters:sourceIndex: Index of String to be copied. Its type is System.Int32 .destination: It is the array of Unicode characters to which characters will be copied. Its type is System.Char[].destinationIndex: It is the the starting index of the array from where the copy operation begins. Its type is System.Int32.count: It is the number of characters which will copy to the destination. Its type is System.Int32.Exceptions:ArgumentNullException: If the destination array is null then it will throw this Exception.ArgumentOutOfRangeException: There are different cases when an exception occursIf sourceIndex, destinationIndex, or count is negative.If sourceIndex does not identify a position in the current instance.If destinationIndex does not identify a valid index in the destination array.If the count is greater than the length of the substring from startIndex to the end of this instanceIf the count is greater than the length of the subarray from destinationIndex to the end of the destination array.Example 2: Using the CopyTo() method to modify an existing character array. C# // C# program to illustrate the // ToCopy() string method using System; class Geeks { public static void Main() { string s = "GeeksForGeeks"; char[] dest = {'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd' }; // str index 8 to 8 + 5 has // to copy into Copystring // 5 is no of character // 6 is start index of Copystring s.CopyTo(8, dest, 6, 5); // Displaying the result Console.Write("String Copied in dest is: "); Console.WriteLine(dest); } } OutputString Copied in dest is: Hello Geeks Create Quiz Comment M Mithun Kumar Follow 1 Improve M Mithun Kumar Follow 1 Improve Article Tags : Misc C# CSharp-method CSharp-string Explore IntroductionC# Tutorial 2 min read Introduction to .NET Framework 6 min read C# .NET Framework (Basic Architecture and Component Stack) 6 min read C# Hello World 2 min read Common Language Runtime (CLR) in C# 4 min read FundamentalsC# Identifiers 2 min read Data Types in C# 6 min read C# Variables 4 min read C# Literals 5 min read Operators in C# 7 min read C# Keywords 5 min read Control StatementsC# Decision Making (if, if-else, if-else-if ladder, nested if, switch, nested switch) 5 min read C# Switch Statement 4 min read Loops in C# 4 min read C# Jump Statements (Break, Continue, Goto, Return and Throw) 4 min read OOP ConceptsClass and Objects in C# 4 min read Constructors in C# 5 min read C# Inheritance 3 min read Encapsulation in C# 2 min read C# Abstraction 4 min read MethodsMethods in C# 4 min read Method Overloading in C# 4 min read Method Parameters in C# 4 min read Method Overriding in C# 7 min read Anonymous Method in C# 2 min read ArraysArrays in C# 6 min read Jagged Arrays in C# 4 min read Array Class in C# 5 min read How to Sort an Array in C# | Array.Sort() Method Set - 1 8 min read How to find the rank of an array in C# 2 min read ArrayListArrayList in C# 6 min read ArrayList Class in C# 4 min read C# | Array vs ArrayList 2 min read StringStrings in C# 6 min read C# Verbatim String Literal - @ 5 min read C# String Class 9 min read C# StringBuilder 2 min read C# String vs StringBuilder 3 min read TupleC# Tuple 7 min read C# Tuple Class 3 min read C# ValueTuple 7 min read C# ValueTuple Struct 4 min read IndexersC# Indexers 5 min read C# Multidimensional Indexers 5 min read C# - Overloading of Indexers 3 min read Like