title: How to get all descriptions of enum values with reflection?
body: <p>So I need to get a <code>List&lt;string&gt;</code> from my <code>enum</code></p>
  
  <p>Here is what I have done so far:</p>
  
  <p><strong>enum definition</strong></p>
  
  <pre><code>    [Flags]
      public enum ContractorType
      {
          [Description("Recipient")]
          RECIPIENT = 1,
          [Description("Deliver")]
          DELIVER = 2,
          [Description("Recipient / Deliver")]
          RECIPIENT_DELIVER = 4
      }
  </code></pre>
  
  <p><strong>HelperClass with method to do what I need:</strong></p>
  
  <pre><code>public static class EnumUtils
  {
      public static IEnumerable&lt;string&gt; GetDescrptions(Type enumerator)
      {
          FieldInfo[] fi = enumerator.GetFields();
  
          List&lt;DescriptionAttribute&gt; attributes = new List&lt;DescriptionAttribute&gt;();
          foreach (var i in fi)
          {
              try
              {
                  yield return attributes.Add(((DescriptionAttribute[])i.GetCustomAttributes(
                      typeof(DescriptionAttribute),
                      false))[0]);
              }
              catch { }
          }
          return new List&lt;string&gt;{"empty"};
      }
  }
  </code></pre>
  
  <p>Now in the line where I <code>yield</code> values, I got a <code>NullReferenceException</code>. Did I miss something? The syntax looks all right to me, but maybe I overlooked something?</p>
  
  <p><strong>Edit:</strong>
  I'm using .net Framework 4.0 here.</p>