Why does the BitArray use LittleEndian?
I'm curious about why System.Collections.BitArray uses Little Endian format.
Was there a reason for this?
http://cplan.cse.msu.edu/cs/blogs/smithiscrazy/archive/2005/04/11/684.aspxAnd I think the BCL people should change it.
BitArray uses little-endian format because you are running your program on a little endian CPU. BitArray stores the bits in an internal array of integers. So if the integers on your platform are little endian, your BitArray will be little endian too. If you look at the internal implementation of the constructor BitArray.BitArray(byte[]) (using a tool like
Lutz Roeder's Reflector), you will notice that the bytes are placed into the integers using bitshifting and masking. So if you execute your code on a big endian CPU, your integers and hence your BitArrays will be big endian.