title: Enum Description to String
body: <p>I have the following ENUM:</p>
  
  <pre><code>[Flags]
  public enum DataFiat {
  
    [Description("Público")]
    Public = 1,
  
    [Description("Filiado")]
    Listed = 2,
  
    [Description("Cliente")]
    Client = 4
  
  } // DataFiat
  </code></pre>
  
  <p>And I created an extension to get an Enum attribute:</p>
  
  <pre><code>public static T GetAttribute&lt;T&gt;(this Enum value) where T : Attribute {
  
    T attribute;
    MemberInfo info = value.GetType().GetMember(value.ToString()).FirstOrDefault();
    if (info != null) {
      attribute = (T)info.GetCustomAttributes(typeof(T), false).FirstOrDefault();
      return attribute;
    }
    return null;
  }
  </code></pre>
  
  <p>This works for non Flags Enums ... But when I have:</p>
  
  <pre><code>var x = DataFiat.Public | DataFiat.Listed;
  var y = x.GetAttribute&lt;Description&gt;();
  </code></pre>
  
  <p>The value of y is null ...</p>
  
  <p>I would like to get "Público, Filiado, Cliente" ... Just as ToString() works.</p>
  
  <p>How can I change my extension to make this work?</p>
  
  <p>Thank You</p>