c# - BitArray creates bits in reverse order -


i have code:

asciiencoding ascii = new asciiencoding(); byte[] bytes= ascii.getbytes("ok"); 

at point, if debug , @ in byte variable, get:

111 107 

which expect. "o" 111 "k" 107

next,

bitarray bits = new bitarray(bytes); 

at point, if debug , @ in bits variable, get:

1 1 1 1 0 1 1 0 1 1 0 1 0 1 1 0 

(the actual array has 'true' 1 , 'false' 0 above).

i wondering why happening , why bit array not populated as

0 1 1 0 1 1 1 1 0 1 1 0 1 0 1 1  

instead.

the bit array returning bits (true or false) in array order. stated, order when in byte format is:

8765 4321

when iterating array, bits returned in order:

1234 5678

it's little confusing when doing mental translation, ordering isn't trying reproduce original bytes.


Comments

Popular posts from this blog

rdbms - what exactly the undo information lives in oracle? -

bash - How do you programmatically add a bats test? -

java - Getting exception in JDBC thin driver -