Question: I would like to have a list of enum values with extended data. The database will only save an integer value corresponding to my enum value, but in code I would like to have more information than just the enum name.

Let me give you an example:

```
public enum Reason
{
    NotEnoughStock, // Valid = yes, Responsability = company, Text = There is not enough stock
    ProductNotAvailabe, // Valid = no, Responsability = company, Text = Produc is not available
    PaymentNotDone, // Valid = no, Responsability = client, Text = Payment is not done
    BlackListedClient, // Valid = no, Responsability = client, Text = Client is black listed
    NotEnoughTime // Valid = yes, Responsability = company, Text = There is not enough time
}

```

How can I do that? Should I use something else than an enum? I like the enumeration.

Answer: 
You could:

* use [Attributes (C#)](https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/attributes/); or
* create helper class that returns the extra information, via something like `Helper.GetExtraInfo(MyType val)`.

---

For the '*Text*' value you could use [DescriptionAttribute](https://learn.microsoft.com/en-us/dotnet/api/system.componentmodel.descriptionattribute?view=netframework-4.8).
For the other two I think you should create new attributes. 

```
class ValidAttribute : Attribute
{
    public bool Valid { get; private set; }

    public ValidAttribute(bool valid)
    {
        this.valid = valid;
    }
}

```

[Get enum from enum attribute](https://stackoverflow.com/questions/2787506/get-enum-from-enum-attribute) contains an extension method to read values of attributes.
You could create an extension method for the enum so that you still can enjoy the enum and getting data in Reason object.

```
var reason = Reason.NotEnoughStock.GetReasonInfo(ReasonData);

```

Sample

```
internal class Program
{
    public static void Main(string[] args)
    {
        var reason = ReasonConstant.Reason.NotEnoughStock.GetReasonInfo(ReasonData);
    }
}

public static class ReasonUtils
{
    public static ReasonInfo GetReasonInfo(this ReasonConstant.Reason reason, Dictionary<ReasonConstant.Reason, ReasonInfo> reasonData)
    {
        if (reasonData == null)
            return null;
        if (!reasonData.ContainsKey(reason))
            return null;
        else
            return reasonData[reason];
    }
}

public class ReasonInfo
{
    public bool IsValid { get; set; }
    public string Responsability { get; set; }
    public string Text { get; set; }
}

public static class ReasonConstant
{
    public enum Reason
    {
        NotEnoughStock, // Valid = yes, Responsability = company, Text = There is not enough stock
        ProductNotAvailabe, // Valid = no, Responsability = company, Text = Produc is not available
        PaymentNotDone, // Valid = no, Responsability = client, Text = Payment is not done
        BlackListedClient, // Valid = no, Responsability = client, Text = Client is black listed
        NotEnoughTime // Valid = yes, Responsability = company, Text = There is not enough time
    }
}

```