An enumeration is a set of named integer constants. Enumerated types are made using the enum keyword.
The C # enumeration is a value type. In other words, enumerations contain their own values and cannot inherit or pass inheritance. General syntax for declaring enumerations: Among them Each symbol in the enumerated list represents an integer value, an integer value larger than the symbol that precedes it. By default, the value of the first enumeration symbol is 0. 0. For example: The following example demonstrates the use of enumerated variables: When the above code is compiled and executed, it produces the following results: 1.33.1. Statement
enum variable # enum <enum_name> { enumeration list };
enum_name specifies the type name of the enumeration. enumeration list is a comma-separated list of identifiers.enum Days { Sun, Mon, tue, Wed, thu, Fri, Sat };
1.33.2. Example #
Example #
using System; public class EnumTest { enum Day { Sun, Mon, Tue, Wed, Thu, Fri, Sat }; static void Main() { int x = (int)Day.Sun; int y = (int)Day.Fri; Console.WriteLine("Sun = {0}", x); Console.WriteLine("Fri = {0}", y); } }
Sun = 0 Fri = 5