HomeCSharpIs this Possible with Enum in C# ?

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

This C# program calculates and displays an upper triangular matrix based on user input. Problem Statement: The program takes the...
This C# program serves as a demonstration of bitwise operators, which are fundamental operators used for manipulating individual bits in...
This C# program is designed to interchange or swap the columns of a matrix. A matrix is a two-dimensional array...