C# byte[] to List<byte[]> -


i'm trying byte[] array 'a' list 'b', it's not working. have byte array 'a'.

12344 23425 34426 34533 

i 4 item (# of rows) list , isn't working. (setting intermediate byte[] adding it)

    byte[] = {1,2,3,4,4,2,3,4,2,5,3,4,4,2,6,3,4,5,3,3};     list<byte[]> b = new list<byte[]>();     byte[] inter_byte= new byte[5];      (int u=0; u<4; u++)     {          (int p=0; p<5; p++)          {                     inter_byte[u] = file[(5*u) + p];          }          b.add(inter_byte);     } 

what i'm getting list 4 rows long, last row. what's best way this?

your byte array reference type, means changing in each loop changes data stored. declaring inside of each loop should work:

 byte[] = {1,2,3,4,4,2,3,4,2,5,3,4,4,2,6,3,4,5,3,3};  list<byte[]> b = new list<byte[]>();   (int u=0; u<4; u++)  {      byte[] inter_byte= new byte[5];      (int p=0; p<5; p++)      {          inter_byte[p] = a[(5*u) + p];      }      b.add(inter_byte);  }         

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -