title: Finding an enum value by its Description Attribute
body: <p>This may seem a little upside down faced, but what I want to be able to do is get an enum value from an enum by its Description attribute.</p>
  
  <p>So, if I have an enum declared as follows:</p>
  
  <pre><code>enum Testing
  {
      [Description("David Gouge")]
      Dave = 1,
      [Description("Peter Gouge")]
      Pete = 2,
      [Description("Marie Gouge")]
      Ree = 3
  }
  </code></pre>
  
  <p>I'd like to be able to get 2 back by supplying the string "Peter Gouge".</p>
  
  <p>As a starting point, I can iterate through the enum fields and grab the field with the correct attribute:</p>
  
  <pre><code>string descriptionToMatch = "Peter Gouge";
  FieldInfo[] fields = typeof(Testing).GetFields();
  
  foreach (FieldInfo field in fields)
  {
      if (field.GetCustomAttributes(typeof(DescriptionAttribute), false).Count() &gt; 0)
      {
          if (((DescriptionAttribute)field.GetCustomAttributes(typeof(DescriptionAttribute), false)[0]).Description == descriptionToMatch)
          {
  
          }
      }
  }
  </code></pre>
  
  <p>But then I'm stuck as to what to do in that inner if. Also not sure if this is the way to go in the first place.</p>