String Copyto() - C# Tutorial
C# Course / Strings / String Copyto()

String Copyto()

BLUF: Mastering String Copyto() is essential for building robust applications with the .NET ecosystem. This tutorial provides clear explanations and practical examples to help you understand and apply this C# concept.
Enterprise Development Tip: String Copyto()

C# is a powerful, modern language for enterprise solutions. Discover how String Copyto() enhances your development workflow in the guide below.

The C# CopyTo function is employed to duplicate a designated quantity of characters from a specific location within the string. It replicates the characters from this string into a char array.

Signature

Example

public void CopyTo(int index, char[] ch, int start, int end)

Parameter

index: An integer type parameter representing the position within a string.

ch: it is a char type array.

start: it is start index of char type array.

end: it is end index of char type array.

C# String CopyTo Method Example

Example

using System;  
    public class StringExample  
    {  
        public static void Main(string[] args)  
        {  
             string s1 = "Hello C#, How Are You?";  
             char[] ch = new char[15];
             s1.CopyTo(10,ch,0,12);
             Console.WriteLine(ch);
        }  
    }

Output:

Output

How Are You?

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience