C# 克隆整个数组
using System; class CloneArray { public static void Main() { string[] array1 = {"a", "b", "c"}; string[] array2 = (string[]) array1.Clone(); DumpArray ("Original array: ", array1); DumpArray ("Cloned array: ", array2); } private static void DumpArray (string title, string[] array) { Console.Write (title); foreach (string s in array) { Console.Write ("{0} ", s); } Console.WriteLine(); } }
这段代码的输出结果如下
Original array: a b c Cloned array: a b c