Q:

Write a C# Sharp program to demonstrate the CopyTo method

0

Write a C# Sharp program to demonstrate the CopyTo method. 

Expected Output :

w3resource CSharp Tutoral                                                        
w3resource Python Tutoral                                                        
w3resourcedifferentutoral

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
public class CopyToExample40 {
    public static void Main() {
        // Embed an array of characters in a string
        string strSource = "Python";
    char [] destination = { 'w', '3', 'r', 'e', 's', 'o', 'u', 'r', 'c', 'e', ' ', 'C',
                'S', 'h', 'a', 'r', 'p', ' ', 'T', 'u', 't', 'o', 'r', 'i', 'a', 'l' };
        // Print the char array
        Console.WriteLine( destination );
        // Embed the source string in the destination string
        strSource.CopyTo ( 0, destination, 11, strSource.Length );
        // Print the resulting array
        Console.WriteLine( destination );
        strSource = "A different string";
        // Embed only a section of the source string in the destination
        strSource.CopyTo ( 2, destination, 10, 9 );
        // Print the resulting array
        Console.WriteLine( destination );
    }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now