Home > Articles > Programming > Windows Programming

  • Print
  • + Share This
From the author of

Statuses in One Single Byte

I need to hold a couple of statuses for each instance—such as dirty, deleted, and expanded, for example. Instead of having one Boolean field for each, I have one Byte field, and let one bit in that Byte field describe each status. To make the code in EntityBase not ugly, I also have private properties for setting and getting the statuses. According to my tests, I saved 35 bytes for one instance in serialization size by doing this.

  • + Share This
  • 🔖 Save To Your Account