c#中的程序,创建一个新的数组(temp),它的大小与mp4v(大数组)不同,然后将此数组(temp)复制到List(a)
程序是:
{
int size; int i = 0;
Int32 [] mp4v=new Int32 [10]{1,12,1,2,11,1,10,4,1,5};
List<Int32> a = new List<Int32>();
Int32[] sz = new Int32[] { 3, 3, 4 };
for (int k = 0; k < 3; k++)
{
size = sz[k];
Int32[] temp = new Int32[size];
Array.Copy(mp4v, i, temp, 0, size);
a.AddRange(temp);
i = i + size;
}
for ( i = 0; i < a.Count; i++)
Console.WriteLine("0", a[i]);
}
output :
0
0
0
0
0
0
0
0
0
0
这个程序出了什么问题,结果一定是这样的:
1
12
1
2
11
1
10
4
1
5