This is more efficient if you use int32 instead of bools, because bitarray uses int32 internally.
public static BitArray Append(this BitArray current, BitArray after) { var ints = new int[(current.Count + after.Count) / 32]; current.CopyTo(ints, 0); after.CopyTo(ints, current.Count / 32); return new BitArray(ints); }
In Vb.net, if someone needs this:
<Runtime.CompilerServices.Extension()> _ Public Function Append(ByVal current As BitArray, ByVal after As BitArray) As BitArray Dim ints = New Int32((current.Count + after.Count) \ 32 - 1) {} current.CopyTo(ints, 0) after.CopyTo(ints, current.Count \ 32) Return New BitArray(ints) End Function
Luiz felipe
source share