I have
Dim bv As New Specialized.BitVector32(25)
Dim sb As String = "0b" 'I resisted the urge to use a stringbuilder
For i As Integer = 31 To 0 Step -1
sb &= IIf(bv(i), 1, 0)
Next
Console.WriteLine(sb)
And I get
0b00000011000000110000001100000011
I only wanted to use BitVector32 for bit flags and I wanted the output to be
0b00000000000000000000000000011001
How do I set this up properly?
The argument to
BitVector32is a mask, not a bit offset.BitArrayis probably closer to what you want.(edit) hmmm – maybe the easiest thing is to use shift operators; in C#:
Also note that index 0 refers to the LSB – so you need to reverse the loop.
Or easier: