Question

I have to create a new bitarray larger of an existing one (one element more at the beginning) and copy it at the end of the new bitarray.

I have done this so far, but looks pretty ugly:

BitArray New_Ft = new BitArray(Ft.Length + 1);
for (int i = 0; i <= Ft.Length - 1; i++) {
    New_Ft(i + 1) = Ft(i);
}

Is there a smarter way (some global copy or so) ?

Était-ce utile?

La solution

Maybe you need to create a temporary array. Not necessary Byte[] could be int[] or Bool[].

        Byte[] bits = new Byte[Ft.Length + 1];
        Ft.CopyTo(bits, 0);
        BitArray New_Ft = new BitArray(bits);
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top