Is this Possible with Enum in C# ?

The enumeration in C# lets the developers to define a limited set of known values.

For example , I can define an enum called Designation as shown below use it in the application.

enum Designation
    {
        Trainee=1,
        SoftwareEngineer = 2,
        Consultant=3
    };

Now , Can i assign duplicate values to enum items ?

Is this Possible with Enum in C# ?

Yes , it is possible to assign duplicate values to the enumeration items . For example , imagine a scenario where  Software Engineers and Consultants needs to have the same value say 2 , below is a code snippet to demonstrate it.

enum Designation
    {
        Trainee=1,
        SoftwareEngineer = 2,
        Consultant=2
    };
If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.
Pin It

Leave a Reply

Your email address will not be published. Required fields are marked *