Difference between enumerators and constants

Hello

What is the difference between enumerators and constants ? Constants seems to be more easier to use than enumerators, because in enumerators you have to cast to int to access the value which leads to more confusion.

I have seen many programs which uses enums than constants. Any specific reason why developers are more biased to enumerators ?
praveenuniAsked:
Who is Participating?
 
DarkoLordConnect With a Mentor Commented:
Hi,

When using enums, you usually don't work with values directly. Usually you use them where there are multiple (but finite) number of possible choices. They are easier to work with, as when developing you can immediately see all possible options, so it's a lot less confusing.

Look at this picture, for example: http://www.braintique.com/csharp/figures/f0105.jpg 
How would you know which integer value is which icon in this case?

Also, enums can be bound to any databound control, so you can for example just bind the entire enum to a ComboBox instead of matching the value/name pairs manually.

Regards,
Darko
0
 
DarkoLordCommented:
0
 
praveenuniAuthor Commented:
Thanks DarkoLord.

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.