title: How to Get Enum By Description Values?
body: <p>I have an enum width descriptions:</p>
  
  <pre><code>  public enum PostTypes {
  
      [Description("Business")]
      Business = 1 &lt;&lt; 0,
  
      [Description("Design"]
      Design = 1 &lt;&lt; 1,
  
      [Description("Marketing")]
      Marketing = 1 &lt;&lt; 2,
  
    } // PostTypes
  </code></pre>
  
  <p>I would like to get an Enum based on Description, so:</p>
  
  <p>1 - If I have String="Business" I would get PostTypes.Business.</p>
  
  <p>2 - If I have String[] = new String[] { "Business", "Design" } I would have PostTypes.Business | PostTypes.Design.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>I am using the following:</p>
  
  <pre><code>Enum.GetValues(typeof(PostTypes)).Cast&lt;PostTypes&gt;().Where(v =&gt; new String[] { "Business", "Design" }.Contains(v.GetDescription())).Aggregate((a, b) =&gt; a | b);
  </code></pre>
  
  <p>This is working even for Flag enums and string arrays.</p>
  
  <p>Could someone, please, help me in creating an extension where I pass the enum type and use a func for setting the rule for search, either the Description attribute or any other.</p>
  
  <p>How can I do this?</p>
  
  <p>Thank You,
  Miguel</p>