C# ARRAYS
January 05, 2024
1 min
An enumeration is a set of named integer constants. An enumerated type is declared using the enum keyword.
C# enumerations are value data type. In other words, enumeration contains its own values and cannot inherit or cannot pass inheritance
Each of the symbols in the enumeration list stands for an integer value, one greater than the symbol that precedes it. By default, the value of the first enumeration symbol is 0. For example:
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace ConsoleApp{class Program{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();}}}
Quick Links
Legal Stuff
Social Media