int[] arr = new int[3] { 3, 2, 1 };
Type type = arr.GetType();
var len = (int)type.GetProperty("Length").GetValue(arr, null);
Type type2 = Type.GetType("System.Int32[]"); //typeof(int[])
var arr2 = Activator.CreateInstance(type2, len);
Debug.WriteLine(type == type2);
Debug.WriteLine(type2.GetProperty("Length").GetValue(arr2, null));
for (int i = 0; i < len; i++)
{
var val = type.GetMethod("Get").Invoke(arr, new object[] { i });
type.GetMethod("Set").Invoke(arr2, new object[] { i, val });
Debug.WriteLine(type.GetMethod("Get").Invoke(arr2, new object[] { i }));
}
用反射创建数组arr2,将数组arr值复制到反射数组arr2