I have several BitArrays that will need to be merged to into 48 byte structure.
BitArray a1 = new (3);
BitArray a2 = new (11);
BitArray a3 = new (14);
//And so on
//Do bit manipulation, etc with the individual Arrays.
Ultimately, I want appended all the together and return a byte[] so I can send them out via UDP. I was thinking of keeping them in an array / list of just iterate thru them and dump them into an ulong - > byte[]
According to this, there isn't really a better way to concatenate two
BitArrays than just "doing it step by step" - make abool[]for the result, copy eachBitArrayinto there, and then make a newBitArrayfrom thebool[].Since you want a
byte[], you can do:Note that you can also convert the
bool[]directly into abyte[]by bit operations if performance is important, like in this answer.