How to efficiently represent an array with a very large bit?

Since a boolean actually takes 1 byte of space , bool[] not the most economical way to represent a bitmap. Sometimes integers and longs are used as a more efficient bit array, but a long one can only contain 64 bits. Is there a more compact way to store tens of millions of bits of arrays in limited memory?

All I need to do with this array is set / clear individual bits and check if some bits are 1 or 0, i.e. the only functions that I need:

 void Set(int index, bool value); bool Get(int index); 
+4
source share
1 answer

I think you need a BitArray class

+11
source

All Articles