From: keeling on
I am surprised that no one pointed out that .NET has a way of treating
Boolean values as bits. Its called... a BitArray (http://
msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx). If
you are concerned with the memory you are using to store Boolean
values (e.g. you have a large collection of them) this may be a
solution for you.

As for why a bool is 4 bytes; my understanding was that it is more
efficient. :-)
From: Rudy Velthuis on
keeling wrote:

> I am surprised that no one pointed out that .NET has a way of treating
> Boolean values as bits. Its called... a BitArray (http://
> msdn.microsoft.com/en-us/library/system.collections.bitarray.aspx).

Well yes, I guess many platforms have such a class. But it requires bit
shifting, etc. Booleans are best stored as single bytes. BitArrays are
useful if you have to store many, many booleans and access time is not
too critical.

--
Rudy Velthuis http://rvelthuis.de

"Think my friends! You adulate a stone as Vishnu but you cannot
see God in a fellow man."
-- Sankaracharya
First  |  Prev  | 
Pages: 1 2 3 4 5
Prev: Using Delegates?
Next: Drag & Drop text