Is there a .NET data type less than a byte?

How about Nibble etc.

+5
source share
3 answers

No. Even if you have an array of logical variables, I believe that they are set for each byte each.

Of course, you can define your own data types that have less than 256 valid values ​​(for example Boolean), but you cannot force it to occupy less than a byte in memory.

As L. Bushkin noted, there are types such as BitArrayand BitVector32that effectively pack several bits efficiently — you could write your own type NybbleArrayif you want.

+14
source
+4

No, the byte is the smallest.

This can be useful: How can you strip out (nybble) bytes in C #?

+1
source

All Articles