Boolean properties in c#

This might be a dumb question It is not. in the property below, will there ever be a situation where just getting it will cause an exception? Possibly, yes. For example, another thread could abort your thread while it was in the middle of fetching that property; that would appear to be an exception thrown … Read more

Why is sizeof(bool) not defined to be one by the C++ standard?

The other likely size for it is that of int, being the “efficient” integer type for the platform. On architectures where it makes any difference whether the implementation chooses 1 or sizeof(int) there could be a trade-off between size (but if you’re happy to waste 7 bits per bool, why shouldn’t you be happy to … Read more

How do I determine if *exactly* one boolean is true, without type conversion?

You can actually accomplish this using only boolean logic, although there’s perhaps no practical value of that in your example. The boolean version is much more involved than simply counting the number of true values. Anyway, for the sake of satisfying intellectual curiosity, here goes. First, the idea of using a series of XORs is … Read more