<aside> Enumerations (enums) are strongly typed constants that help make code more readable and maintainable by giving meaningful names to a set of related values.

</aside>

📚 Understanding Enums

Enums are value types that define a set of named constants. They're perfect for representing fixed sets of options or states.

🔧 Basic Enum Structure

public enum DaysOfWeek 
{
    Sunday,    // 0
    Monday,    // 1
    Tuesday,   // 2
    Wednesday, // 3
    Thursday,  // 4
    Friday,    // 5
    Saturday   // 6
}

<aside> 💡 By default, enum values start at 0 and increment by 1, but you can assign custom values!

</aside>

🎯 Custom Values

public enum Permissions
{
    None = 0,
    Read = 1,
    Write = 2,
    Execute = 4,
    All = Read | Write | Execute
}

📝 Common Use Cases

🔄 Working with Enums

// Declaring enum variable
DaysOfWeek today = DaysOfWeek.Friday;

// Converting enum to string
string dayName = today.ToString();  // "Friday"

// Converting string to enum
DaysOfWeek day = Enum.Parse<DaysOfWeek>("Monday");

// Getting all enum values
DaysOfWeek[] allDays = Enum.GetValues<DaysOfWeek>();

// Checking if value exists
bool isValid = Enum.IsDefined(typeof(DaysOfWeek), "Sunday");

⚡ Best Practices