.net - C# Split array into fixed number of ranges -


i have byte[] array of length , want split parts , each part have length of 2205 , have operations on 2205 bytes, here algorithm:

// split 2205 bytes int block = 2205; int counter = 0; byte[] to_send = new byte[block]; foreach (byte b in archieve_buffer) {     if (counter < 2205)     {         to_send[counter] = b;         counter++;     }     else if (counter == 2205)     {         // operation on 2205 bytes stored on array to_send          counter = 0;         to_send[counter] = b;         counter++;     } } 

i wanna split array fixed number of ranges

using linq can split array blocksize bytes blocks

int count=0; int blocksize = 2205; list<list<byte>> blocks =  archieve_buffer                             .groupby( _ => count++ / blocksize)                             .select(x=>x.tolist())                             .tolist(); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -