请教怎么实现数组copy
请问如何实现数组copy?
比如说有数组A,{0,1,2,3}
我想把A拷贝到B数组,B = {0,1,2}
有没有现成的函数?我不想用for循环
------------------------------------------------
A = {0,1,2,3}
||
B = {0,1,2}
------解决方案--------------------
LZ,你这两个数组的维数都不一样啊,怎么复制呢?没有搞懂LZ的意思...
------解决方案--------------------
int[] A = new int[] { 1, 2, 3, 4, 5 };
int[] B = new int[3];
Array.Copy(A, B, B.Length);
foreach (int temp in B)
{
Console.WriteLine(temp);
}
比如说有数组A,{0,1,2,3}
我想把A拷贝到B数组,B = {0,1,2}
有没有现成的函数?我不想用for循环
------------------------------------------------
A = {0,1,2,3}
||
B = {0,1,2}
------解决方案--------------------
LZ,你这两个数组的维数都不一样啊,怎么复制呢?没有搞懂LZ的意思...
------解决方案--------------------
int[] A = new int[] { 1, 2, 3, 4, 5 };
int[] B = new int[3];
Array.Copy(A, B, B.Length);
foreach (int temp in B)
{
Console.WriteLine(temp);
}