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: 
With combined help of tymtam and Kevin I did this:

```
void Main()
{
    Reason.NotEnoughStock.GetAttributeOfType<DescriptionAttribute>().Description;
    Reason.ProductNotAvailabe.GetAttributeOfType<ResponsabilityAttribute>().Responsability;
}

public enum Reason
{
    [Description("There is not enough stock")]
    [Valid(true)]
    [Responsability("company")]
    NotEnoughStock, 

    [Description("Produc is not available")]
    [Valid(false)]
    [Responsability("company")]
    ProductNotAvailabe,

    [Description("Payment is not done")]
    [Valid(false)]
    [Responsability("client")]
    PaymentNotDone, 

    [Description("Client is black listed")]
    [Valid(false)]
    [Responsability("client")]
    BlackListedClient, 

    [Description("There is not enough time")]
    [Valid(true)]
    [Responsability("company")]
    NotEnoughTime 
}

public static class EnumHelper
{
    /// <summary>
    /// Gets an attribute on an enum field value
    /// </summary>
    /// <typeparam name="T">The type of the attribute you want to retrieve</typeparam>
    /// <param name="enumVal">The enum value</param>
    /// <returns>The attribute of type T that exists on the enum value</returns>
    /// <example>string desc = myEnumVariable.GetAttributeOfType<DescriptionAttribute>().Description;</example>
    public static T GetAttributeOfType<T>(this Enum enumVal) where T : System.Attribute
    {
        var type = enumVal.GetType();
        var memInfo = type.GetMember(enumVal.ToString());
        var attributes = memInfo[0].GetCustomAttributes(typeof(T), false);
        return (attributes.Length > 0) ? (T)attributes[0] : null;
    }
}

public class ValidAttribute : Attribute
{
    public bool Valid;
    public ValidAttribute(bool valid) { Valid = valid; }
}

public class ResponsabilityAttribute : Attribute
{
    public string Responsability;
    public ResponsabilityAttribute(string responsability) { Responsability = responsability; }
}

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

```