When and Why do we need an "ENUM" ? [Resolved]

Posted by Akiii under C# on 10/24/2011 | Points: 10 | Views : 3314 | Status : [Member] | Replies : 2
Hi folks,

Can anyone tell me when and why do we need an "ENUM" "?
Any real life scenario ?

Thanks and Regards
Akiii




Responses

Posted by: SheoNarayan on: 10/24/2011 [Administrator] HonoraryPlatinum | Points: 50

Up
0
Down

Resolved
Enumeration is a user defined integer type that allows us to give user friendly names. It is generally used when we have limited number of numeric choices and want to convey these choices with user friendly names.

It makes our codes cleaner, easier to maintain and easy to remember as Visual Studio provides its intellisense.

For example:

enum Day

{
Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday
}


In the above code snippet, Sunday is 0, Monday is 1 and so on.

Below are some post that should help you.

http://www.dotnetfunda.com/codes/code915-binding-enumerations-to-the-gridview.aspx
http://www.dotnetfunda.com/codes/code1473-list-all-the-enumeration-values.aspx
http://www.dotnetfunda.com/forums/thread4660-what-is-enumeration-enum.aspx

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Akiii on: 11/6/2011 [Member] Bronze | Points: 25

Up
0
Down
thank you for the answer..

Regards
Akiii

Akiii, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response