I have a byte array:
byte[] bytes; // many elements
I need to divide it into subsequence of byte arrays of X elements. For example, x = 4.
If bytes.Length does not multiply by X, then add 0 to last subsequence array so Length of all subsequnce must be X.
Linq available.
PS: my attempts
static void Main(string[] args)
{
List<byte> bytes = new List<byte>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 };
int c = bytes.Count / 4;
for (int i = 0; i <= c; i+=4)
{
int diff = bytes.Count - 4;
if (diff < 0)
{
}
else
{
List<byte> b = bytes.GetRange(i, 4);
}
}
Console.ReadKey();
}
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…