I'm trying to compare the enum element with the database value;
Comparing the names(Value) works fine but the names are subjects to change so i have to compare by IDs which is why i assigned numbers to each enum element;

Testing the comparation includes getting the random element from the list of some(not all) string extension values of said enum.

Is there any way to get the assigned number of the element or at least index after random variable(randomElemnt) is set?

I tried to create another variable

```
var randomElemntId = (ProductName)Enum.Parse(typeof(ProductName),randomElemnt);

```

Casting to an int didn't yield desirable result either.

This is my example enum with string extension Value

```
//Value is a string extension
public enum ProductName
    {
        [Value("Product1")] Product1 = 2,
        [Value("Product2")] Product2 = 3,
        [Value("Product3")] Product3 = 4,
        [Value("Product4")] Product4 = 1,
        [Value("None")] None = 0
    }

```

Example of a list that i use. Note that not all of the enum elements are present; Variable which gets random element of the list

```
//contains some enum values
     var Products = new List<string>
            {
                ProductName.Product1.GetValue(),
                ProductName.Product2.GetValue(),
                ProductName.Product3.GetValue(),

            };

//returns random element from the list
var randomElemnt = Products.RandomElement();

```