C# String CopyTo() Method
You are Here:
C# String CopyTo()
The CopyTo()
method copies a specified number of characters from the specified position in the string to a specified position in an array of characters.
Example
C# Compiler
using System;
namespace myApp
{
class Program
{
static void Main(string[] args)
{
string s1 = "John doe";
char[] ch = new char[15];
s1.CopyTo(1, ch, 0, 7);
Console.Write(ch);
}
}
}
Output
ohn doe
Syntax
public void s1.CopyTo(int index, char[] ch, int start, int end)
Parameter Values
Value | Type | Explanation |
---|---|---|
index | Required | Specifies the starting position of the source String to be copied. |
ch | Required | Specifies the character array. |
start | Required | Specifies the start index of the character array. |
end | Required | Specifies the end index of the character array. |
Return Value
Value | Explanation |
---|---|
- | Returns nothing. |
Reminder
Hi Developers, we almost covered 90% of String functions and Interview Question on C# with examples for quick and easy learning.
We are working to cover every Single Concept in C#.
Please do google search for:
Join Our Channel
Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.
This channel is primarily useful for Full Stack Web Developer.