How to copy one array into another array ?

 Posted by Bharathi Cherukuri on 7/30/2012 | Category: C# Interview questions | Views: 2649 | Points: 40
Answer:

We can copy one array into another array by using copy To() method.

Example:

using System;
namespace ConsoleApplication
{
class Program
{
static void Main()
{
int[] Numbers = { 2, 5, 3, 1, 4 };
int[] CopyOfNumbers=new int[5];
Numbers.CopyTo(CopyOfNumbers,0);
foreach (int i in CopyOfNumbers)
{
Console.WriteLine(i);
}
}
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response