title: Is it possible to add custom properties to c# enum object?
body: <p>Using c# Is it possible using to associate properties for each enum items?</p>
  
  <p>I have used the <a href="https://msdn.microsoft.com/en-us/library/system.componentmodel.descriptionattribute(v=vs.110).aspx" rel="nofollow noreferrer">Description Attribute</a> to add English description to an <code>enum</code> item.</p>
  
  <p>To add English description to each item I have done the following</p>
  
  <pre><code>public enum MyEnum
  {
      [Description("My First Item")]
      First,
  
      [Description("My Second Item")]
      Second,
  
      [Description("My Third Item")]
      Third
  }
  </code></pre>
  
  <p>Then I added an extension method to my <code>enum</code> called <code>GetDescription()</code> which allows me to get the description like so</p>
  
  <pre><code>public static string GetDescription(this Enum value)
  {
      Type type = value.GetType();
  
      string name = Enum.GetName(type, value);
  
      if (name != null)
      {
          FieldInfo field = type.GetField(name);
          if (field != null)
          {
              DescriptionAttribute attr = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute;
              if (attr != null)
              {
                  return attr.Description;
              }
          }
      }
  
      return name;
  }
  </code></pre>
  
  <p>However, it will help me a lot if I am able to assign a class or construct a new object.</p>
  
  <p>Is it possible/How can I do something like the follow?</p>
  
  <pre><code>public enum MyEnum
  {
      [Description("My First Item"), new { IsFirst = true, UnitType = 1}]
      First
  }
  </code></pre>
  
  <p>or using a class</p>
  
  <pre><code>public enum MyEnum
  {
      [Description("My First Item"), new MyCustomClass(true, 1)]
      First
  }
  </code></pre>