Answered by:
enum

Question
-
what is the enum
Saturday, July 10, 2010 12:43 PM
Answers
-
Hi,
An enumeration is a set of named constants. Please refer to the MSDN-documentation for further details:
System.Enum-Class:
http://msdn.microsoft.com/en-us/library/system.enum.aspxMarcel
- Proposed as answer by Erik Cassel Tuesday, July 13, 2010 4:44 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Saturday, July 10, 2010 12:56 PM -
Enum is a set of constants. The problem is most people do not use enums in their code because they are not aware on when and where they can use it.
For example for a conditional flow rather than using int type variables you can use enums. This adds much readability in your code.
enum choice : int {Coke, RedBull, Boost}
if ( opt == choice.Coke)
{
}
else
{
}
Here rather using a string this is efficient because in the underlying architecture the enum uses int type indexes and this more readable than directly using integers.
Other than that you can specify values to enums and access them as well
Regards Puboo My blog : http://thurupathan.spaces.live.com- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 3:24 AM -
Hi sateesh1234,
Welcome to MSDN forums! what is the enum? Hope this will help you!
Enum is a costum data type(value type) in c# and the enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.
Get more enum information please refer to http://msdn.microsoft.com/en-us/library/sbbt4032%28VS.80%29.aspx
If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.
Best Regards,
Yan Jun
Microsoft Online Community Support- Proposed as answer by Paras Sanghani Wednesday, July 14, 2010 7:55 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 6:55 AMModerator -
Hello Sateesh1234,
Kindly find the below lines for your understanding on Enums.
What is Enum and how to create it?
Enum(Enumerations) are related symbols that have fixed values. Use enumerations to provide a list of choices for developers using your class. For example, the following enumeration contains a set of titles:
If you create an instance of the Titles type, Visual Studio displays a list of the available values when you assign a value to the variable. Although the value of the variable is an integer, it is easy to output the name of the symbol rather than its value, as shown here:
' VB Dim t As Titles = Titles.Dr Console.WriteLine("{0}.", t) ' Displays "Dr." // C# Titles t = Titles.Dr; Console.WriteLine("{0}.", t); // Displays "Dr."
The purpose of enumerations is to simplify coding and improve code readability by enabling you to use meaningful symbols instead of simple numeric values. Use enumerations when developers consuming your types must choose from a limited set of choices for a value.
Kindly, let me know if you need further understanding.
Thanks,
Paras Sanghani
Mark As Answer if it helped you.
- Proposed as answer by Paras Sanghani Tuesday, July 13, 2010 8:29 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 7:47 AM -
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Wednesday, July 14, 2010 7:35 AM
All replies
-
Hi,
An enumeration is a set of named constants. Please refer to the MSDN-documentation for further details:
System.Enum-Class:
http://msdn.microsoft.com/en-us/library/system.enum.aspxMarcel
- Proposed as answer by Erik Cassel Tuesday, July 13, 2010 4:44 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Saturday, July 10, 2010 12:56 PM -
Enum is a set of constants. The problem is most people do not use enums in their code because they are not aware on when and where they can use it.
For example for a conditional flow rather than using int type variables you can use enums. This adds much readability in your code.
enum choice : int {Coke, RedBull, Boost}
if ( opt == choice.Coke)
{
}
else
{
}
Here rather using a string this is efficient because in the underlying architecture the enum uses int type indexes and this more readable than directly using integers.
Other than that you can specify values to enums and access them as well
Regards Puboo My blog : http://thurupathan.spaces.live.com- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 3:24 AM -
Hi sateesh1234,
Welcome to MSDN forums! what is the enum? Hope this will help you!
Enum is a costum data type(value type) in c# and the enum keyword is used to declare an enumeration, a distinct type consisting of a set of named constants called the enumerator list. Every enumeration type has an underlying type, which can be any integral type except char. The default underlying type of the enumeration elements is int. By default, the first enumerator has the value 0, and the value of each successive enumerator is increased by 1.
Get more enum information please refer to http://msdn.microsoft.com/en-us/library/sbbt4032%28VS.80%29.aspx
If you still have any doubt and concern about this issue, please let me know. If I misunderstood you, please kindly elaborate your question.
Please Mark as Answered If this is helpful Or Un-Mark as Answered if it is not helpful.
Best Regards,
Yan Jun
Microsoft Online Community Support- Proposed as answer by Paras Sanghani Wednesday, July 14, 2010 7:55 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 6:55 AMModerator -
Hello Sateesh1234,
Kindly find the below lines for your understanding on Enums.
What is Enum and how to create it?
Enum(Enumerations) are related symbols that have fixed values. Use enumerations to provide a list of choices for developers using your class. For example, the following enumeration contains a set of titles:
If you create an instance of the Titles type, Visual Studio displays a list of the available values when you assign a value to the variable. Although the value of the variable is an integer, it is easy to output the name of the symbol rather than its value, as shown here:
' VB Dim t As Titles = Titles.Dr Console.WriteLine("{0}.", t) ' Displays "Dr." // C# Titles t = Titles.Dr; Console.WriteLine("{0}.", t); // Displays "Dr."
The purpose of enumerations is to simplify coding and improve code readability by enabling you to use meaningful symbols instead of simple numeric values. Use enumerations when developers consuming your types must choose from a limited set of choices for a value.
Kindly, let me know if you need further understanding.
Thanks,
Paras Sanghani
Mark As Answer if it helped you.
- Proposed as answer by Paras Sanghani Tuesday, July 13, 2010 8:29 AM
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Tuesday, July 13, 2010 7:47 AM -
- Marked as answer by FafafaalexModerator Friday, July 16, 2010 9:49 AM
Wednesday, July 14, 2010 7:35 AM