How do I convert List<byte[]>
in one byte[]
array, or one Stream
?
The recommended solution to concatenate two or more byte arrays is using ByteArrayOutputStream . The idea is to write bytes from each of the byte arrays to the output stream, and then call toByteArray() to get the current contents of the output stream as a byte array.
you can use the linq method: MyBytes. Reverse() as well as the Array. Reverse() method.
A byte is 8 bits (binary data). A byte array is an array of bytes (tautology FTW!). You could use a byte array to store a collection of binary data, for example, the contents of a file. The downside to this is that the entire file contents must be loaded into memory.
bytes is an immutable version of bytearray – it has the same non-mutating methods and the same indexing and slicing behavior. Syntax: bytes([source[, encoding[, errors]]]) bytearray() function : Return a new array of bytes. The bytearray type is a mutable sequence of integers in the range 0 <= x < 256.
SelectMany
should do the trick:
var listOfArrays = new List<byte[]>();
byte[] array = listOfArrays
.SelectMany(a => a)
.ToArray();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With