Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friends
i want to concatenate to byte[] array values into single byte[] in asp.net. i could not find right code for it in asp.net


please can anyone help me:



thanx
Posted

I use this function to concat 2 or more byte arrays

C#
private byte[] CombineByteArrays(params byte[][] arrays)
{
  byte[] rv = new byte[arrays.Sum(a => a.Length)];
  int offset = 0;
  foreach (byte[] array in arrays)
  {
    System.Buffer.BlockCopy(array, 0, rv, offset, array.Length);
    offset += array.Length;
  }
  return rv;
}


I the use the function like this
byte[] header, body, footer; // All byte arrays a fill with data

byte[] content = CombineByteArrays(header, body, footer);
networkStream1.Write(content, 0, content.Length);
 
Share this answer
 
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900