public static byte[] addBytes(byte[] data1, byte[] data2, byte[] data3)
{
if (data1.Length.Equals(0) || data2.Length.Equals(0))
{
if (data3.Length.Equals(0))
{
if (data1.Length.Equals(0))
{
return data2;
}
else
{
return data1;
}
}
else
{
if (data1.Length.Equals(0))
{
byte[] result = new byte[data2.Length + data3.Length];
Buffer.BlockCopy(data2, 0, result, 0, data2.Length);
Buffer.BlockCopy(data3, 0, result, data2.Length, data3.Length);
return result;
}
else
{
byte[] result = new byte[data1.Length + data3.Length];
Buffer.BlockCopy(data1, 0, result, 0, data1.Length);
Buffer.BlockCopy(data3, 0, result, data1.Length, data3.Length);
return result;
}
}
}
else if (data1.Length.Equals(0) && data2.Length.Equals(0))
{
return data3;
}
else
{
byte[] result = new byte[data1.Length + data2.Length + data3.Length];
Buffer.BlockCopy(data1, 0, result, 0, data1.Length);
Buffer.BlockCopy(data2, 0, result, data1.Length, data2.Length);
Buffer.BlockCopy(data3, 0, result, data1.Length + data2.Length, data3.Length);
return result;
}
}
来源:CSDN
作者:艾孜尔江
链接:https://blog.csdn.net/weixin_43867242/article/details/104268091