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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DarkoLordCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DarkoLordCommented:
0
praveenuniAuthor Commented:
Thanks DarkoLord.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.