>>>>我在一个arraylist保存了一些字节数组,有什么简单方法把所有的字节数组组合成一个完整的数组? if I understand you correctly, try something like the following, note, only one new array object is created, the strings are not duplicatedArrayList al = new ArrayList(); string[] s = {"1","2","3"}; al.Add(s);string[] s2 = {"4","5","6"}; al.Add(s2);string[] s3 = {"7","8","9"}; al.Add(s3);int nCount = 0; foreach (string[] x in al) nCount += x.Length;string[] y = new string[nCount];int i=0; foreach(string[] x in al) { x.CopyTo(y,i); i+=x.Length; }
string[] s = {"1","2","3"};
al.Add(s);string[] s2 = {"4","5","6"};
al.Add(s2);string[] s3 = {"7","8","9"};
al.Add(s3);int nCount = 0;
foreach (string[] x in al)
nCount += x.Length;string[] y = new string[nCount];int i=0;
foreach(string[] x in al)
{
x.CopyTo(y,i);
i+=x.Length;
}