title: Get Enum by Custom Attribute (Generic)
body: <p>There are a lot of examples in which you can Get Enum by Custom attribute like here
  <a href="https://stackoverflow.com/questions/4367723/get-enum-from-description-attribute">Get Enum from Description attribute</a></p>
  
  <pre><code>public static class EnumEx
  {
      public static T GetValueFromDescription&lt;T&gt;(string description)
      {
          var type = typeof(T);
          if(!type.IsEnum) throw new InvalidOperationException();
          foreach(var field in type.GetFields())
          {
              var attribute = Attribute.GetCustomAttribute(field,
                  typeof(DescriptionAttribute)) as DescriptionAttribute;
              if(attribute != null)
              {
                  if(attribute.Description == description)
                      return (T)field.GetValue(null);
              }
              else
              {
                  if(field.Name == description)
                      return (T)field.GetValue(null);
              }
          }
          throw new ArgumentException("Not found.", "description");
          // or return default(T);
      }
  }
  </code></pre>
  
  <p>But here the problem is that you have to hardcode the attributeType i.e. <code>typeof(DescriptionAttribute)) as DescriptionAttribute</code></p>
  
  <p>How do i convert this example into Generic extension so that i dont have to hardcoded the CustomAttributeType.</p>