///
/// 将大数组拆分为多个小数组
///
/// 需要拆分原始数组
/// 拆分后单个数组大小
///
public List SplitList(byte[] superbyte , int size)
{
List result = new List();
int length = superbyte.Length;
int count = length / size;
int r = length % size;
for (int i = 0; i < count; i++)
{
byte[] newbyte = new byte[size];
newbyte = superbyte.Skip(size * i).Take(size).ToArray();// SplitArray(superbyte, size*i, size * i+ size);
result.Add(newbyte);
}
if (r != 0)
{
byte[] newbyte = new byte[r];
newbyte = superbyte.Skip(length - r).Take(r).ToArray();
result.Add(newbyte);
}
return result;
}
数组拆分方法
本文介绍了一种将大数组拆分成多个指定大小的小数组的方法。通过使用C#语言实现的SplitList函数,可以有效地处理数组拆分任务。此方法首先确定原始数组的长度,并计算出每个小数组应该包含的元素数量,最后通过循环遍历完成拆分。
650

被折叠的 条评论
为什么被折叠?



