I tried to use the List.ConvertAll method and failed. What I am trying to do is convert a List
to byte[]
I copped out and went
Since you don't want a byte[][]
where each integer maps to an array of four bytes, you cannot call ConvertAll
. (ConvertAll
cannot perform a one-to-many conversion)
Instead, you need to call the LINQ SelectMany
method to flatten each byte array from GetBytes
into a single byte[]
:
integers.SelectMany(BitConverter.GetBytes).ToArray()