How to Declare an Enumeration with Explicit Values in C# ?

There are times when you want to have a specific values to the enumeration to the enum items . For example , if you need to match particular values from the database or from a web service etc.

How to Declare an Enumeration with Explicit Values in C# ?

Below is a sample code snippet that demonstrates how to declare an enum with explicit values in C#.

enum EmployeeDesignation
    {
        Trainee=1,
        SoftwareEngineer = 3,
        SeniorSoftwareEngineer=5
    };

%d bloggers like this: