Can enum have attributes?

An enum can, just like a class , have attributes and methods . The only difference is that enum constants are public , static and final (unchangeable – cannot be overridden). An enum cannot be used to create objects, and it cannot extend other classes (but it can implement interfaces).

Read more

What is enum & why it is used?

Enums are lists of constants . When you need a predefined list of values which do represent some kind of numeric or textual data, you should use an enum. You should always use enums when a variable (especially a method parameter) can only take one out of a small set of possible values.

Read more

How do I list enums?

The idea is to use the Enum. GetValues() method to get an array of the enum constants’ values. To get an IEnumerable<T> of all the values in the enum, call Cast<T>() on the array. To get a list, call ToList() after casting .

Read more