Home > DeveloperSection > Interviews > Define enumeration?

Posted on    August-27-2014 11:45 PM

 C# C# 
 1 Answer(s)
  778  View(s)
Rate this:

Sumit Kesarwani

Total Post:782

Posted on    August-27-2014 12:00 AM

Enumeration is defined as a value type that consists of a set of named values. These values are constants and are called enumerators. An enumeration type is declared using the enum keyword. Each enumerator in an enumeration is associated with an underlying type that is set, by default, on the enumerator. The following is an example that creates an enumeration to store different varieties of fruits:

enum Fruits {Mango, Apple, orange, Guava};

In the preceding example, an enumeration Fruits is created, where number 0 is associated with Mango, number 1 with Apple, number 2 with Orange, and number 3 with Guava. You can access the enumerators of an enumeration by these values.

Don't want to miss updates? Please click the below button!

Follow MindStick