byte[] a = new byte[] { 1, 2, 3 }; byte[] b = new byte[] { 4, 5, 6, 7 }; byte[] c = new byte[a.Length+b.Length]; Array.Copy(a, 0, c, 0, a.Length); Array.Copy(b, 0, c, a.Length, b.Length);
新建一个byte数组作为中间变量
public string test() { byte[] a = new byte[] { 1, 2, 3 }; byte[] b = new byte[] { 4, 5, 6, 7 }; byte[] c = new byte[a.Length + b.Length]; Array.Copy(a, 0, c, 0, a.Length); Array.Copy(b, 0, c, a.Length, b.Length); string te; StringBuilder sb = new StringBuilder(); ; for (int i = 0; i < c.Length; i++) { sb.Append(c[i]); } string te; te = sb.ToString(); return te; }
byte[] a = new byte[80]; byte[] b = new byte[100]; byte[] c = new byte[a.Length + b.Length]; Buffer.BlockCopy(a, 0, c, 0, a.Length); Buffer.BlockCopy(b, 0, c, a.Length, c.Length); b = c;
byte[] b = new byte[] { 4, 5, 6, 7 };
byte[] c = new byte[a.Length+b.Length]; Array.Copy(a, 0, c, 0, a.Length);
Array.Copy(b, 0, c, a.Length, b.Length);
{
byte[] a = new byte[] { 1, 2, 3 };
byte[] b = new byte[] { 4, 5, 6, 7 };
byte[] c = new byte[a.Length + b.Length];
Array.Copy(a, 0, c, 0, a.Length);
Array.Copy(b, 0, c, a.Length, b.Length);
string te;
StringBuilder sb = new StringBuilder(); ;
for (int i = 0; i < c.Length; i++)
{
sb.Append(c[i]);
}
string te;
te = sb.ToString();
return te;
}
byte[] b = new byte[100];
byte[] c = new byte[a.Length + b.Length];
Buffer.BlockCopy(a, 0, c, 0, a.Length);
Buffer.BlockCopy(b, 0, c, a.Length, c.Length);
b = c;