HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Enumeration is a set of named integer constants. Enumerated type is declared usingenum keyword.
C # is a value enumeration data type. In other words, the enumeration contains its own value and can not be inherited or transfer inheritance.
The general syntax statement enumeration:
enum <enum_name> { enumeration list };
among them,
Enumerated list Each symbol represents an integer value larger than a signed integer value that precedes it. By default, the value of the first enumeration symbol is 0. For example:
enum Days {Sun, Mon, tue, Wed, thu, Fri, Sat};
The following example demonstrates the use of enumeration:
using System; namespace EnumApplication { class EnumProgram { enum Days {Sun, Mon, tue, Wed, thu, Fri, Sat}; static void Main (string [] args) { int WeekdayStart = (int) Days.Mon; int WeekdayEnd = (int) Days.Fri; Console.WriteLine ( "Monday: {0}", WeekdayStart); Console.WriteLine ( "Friday: {0}", WeekdayEnd); Console.ReadKey (); } } }
When the above code is compiled and executed, it produces the following results:
Monday: 1 Friday: 5