+ 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?

30th May 2017, 9:45 PM
Dot
Dot - avatar
2 ответов
+ 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.
30th May 2017, 10:15 PM
Thanh Le
Thanh Le - avatar
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.
31st May 2017, 5:13 AM
1of3
1of3 - avatar