A side dish: if you need some type with values 0 or 1 only, this is what you should do:
enum Discrete : byte { Low = 0, Hight = 1, }
It will force writing correct code at compile time but won't prevent other values during run-time (the fact which can be used to the benefit as well).
[EDIT]
Why not boolean? There are important applications for that. Here is the example. Imagine a numeric calculation using or not using certain special factor. What to do? Using "
if (useSpecialFactor) //...
"? Nah! Look:
enum SpecialFactorUse { Ignore = 0, Use = 1, }
double Calculate(SpecialFactorUse specialFactorUse ) {
return mainFactor + specialFactor * (int)specialFactorUse;
}
enum Direction { Left = -1, StayHere = 0, Right = +1, }
Direction direction = getNewDirection(currentDirection, arrowKeys);
double newPosition = currentPosition + step * (int)direction;
—SA