C# EnumEnum in C# is also known as enumeration. It is used to store a set of named constants such as season, days, month, size etc. The enum constants are also known as enumerators. Enum in C# can be declared within or outside class and structs. Enum constants has default values which starts from 0 and incremented to one by one. But we can change the default value. Points to remember
C# Enum ExampleLet's see a simple example of C# enum. Output: WINTER = 0 SUMMER = 2 C# enum example changing start indexOutput: WINTER = 10 SUMMER = 12 C# enum example for DaysOutput: Sun = 0 Mon = 1 Sat = 6 C# enum example: traversing all values using getNames()Output: Sun Mon Tue Wed Thu Fri Sat C# enum example: traversing all values using getValues()Output: Sun Mon Tue Wed Thu Fri Sat Next TopicC# Properties |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India