请问两个byte[]类型的数据如何合并成一个

解决方案 »

  1.   

    byte[] byte1 = ....
    byte[] byte2 = ......
    byte[] byte3 = new byte[ byte1.Length + byte2.Length];
    Array.Copy( byte1 , 0 , byte3 , 0 , byte1.Length );
    Array.Copy( byte2 , 0 , byte3 , byte1.Length  , byte2.Length );
      

  2.   

    byte[] byte1 ={0,1,2};
    byte[] byte2 = {3,4,5}; ArrayList al = new ArrayList();
    foreach (byte b in byte1)
    {
    al.Add(b);
    } foreach (byte b in byte2)
    {
    al.Add(b);
    }
    byte[] byte3 = (byte[])al.ToArray(typeof(byte));
      

  3.   

    byte[] byte1 = ....
    byte[] byte2 = ......
    byte[] byte3 = new byte[ byte1.Length + byte2.Length];
    Array.Copy( byte1 , 0 , byte3 , 0 , byte1.Length );
    Array.Copy( byte2 , 0 , byte3 , byte1.Length  , byte2.Length );