+ 4
Enum
you know! I never could understand "Enum" in c#...or java... can any body help me? what is it for? when we use it? how to use it?
2 Answers
+ 5
usually to make sure, only certain sets of values are allowed to pick and/or to replace any "magic number" (that is any seemingly arbitrary and repetitive numbers in your code) with more descriptive names.
0
Say you have some orders for a system like START, STOP, PAUSE. There are no other possible orders. How to encode them?
In general, whenever you say: These are the only possible options. Then you use enum. In well typed languages, the compiler will make sure that no other thing goes where you expect one of you enum members.