C#将字节数组拆分成指定长度的字节数组

/// <summary>
/// 将字节数组拆分指定长度数组
/// </summary>
/// <param name="buffer">字节数组</param>
/// <param name="blockLength">拆分成数组长度</param>
/// <returns></returns>
private List<byte[]> SplitBuffer(byte[] buffer, int blockLength)
{
List<byte[]> list = new List<byte[]>();

int offset = 0;

while (buffer.Length - offset > 0)
{
byte[] tmp = buffer.Take(offset + blockLength).Skip(offset).ToArray();
list.Add(tmp);

offset += blockLength;
}
return list;
}

posted @ 2021-01-19 11:08  XQ_Drong  阅读(120)  评论(0)    收藏  举报