Array.Copy可以复制整个数组,也可以对数组进行部分复制
using System; public class CopyArray { public static void Main() { int[] integers = new int[] {5, 10, 15}; double[] doubles = new double[3]; Array.Copy (integers, doubles, 2); Console.Write ("integers array elements:" ); foreach (int integer in integers) { Console.Write("{0,3}", integer); } Console.Write ("\ndoubles array elements:" ); foreach (double duble in doubles) { Console.Write ("{0,3}", duble); } Console.WriteLine(); } }
上面代码的执行结果如下:
integers array elements: 5 10 15 doubles array elements: 5 10 0