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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -