public byte[] GetMsgAtTail(int spieces, byte[] msg2Spilt)
{
int remainder = msg2Spilt.Length % spieces;
byte[] result = new byte[(msg2Spilt.Length - remainder) / spieces];
if (spieces.Equals(0))
{
return msg2Spilt;
}
else if (!remainder.Equals(0))
{
byte[] volumLeft = new byte[remainder * spieces];
Buffer.BlockCopy(msg2Spilt, (msg2Spilt.Length - spieces * remainder), volumLeft, 0, volumLeft.Length);
return volumLeft;
}
else
{
Buffer.BlockCopy(msg2Spilt, (msg2Spilt.Length - msg2Spilt.Length / spieces), result, 0, result.Length);
return result;
}
}
将一个字节数组传入,方法会将字节数组分隔成指定的份数,返回最末尾那一份的字节数组。
——艾孜尔江撰。