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
    };

Leave A Reply

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

You May Also Like

C# Compiler Error CS0442 – ‘Property’: abstract properties cannot have private accessors Reason for the Error You’ll get this error...
This is a really simple one . Below is a simple example of an enum called “Designation” defined with the...
This blog post explain the usage of the Checked Block in .NET and how you can use them in Visual...