title: Linking enum value with localized string resource
body: <p>Related:
  <a href="https://stackoverflow.com/questions/2787506/cast-string-to-enum-with-enum-attribute">Get enum from enum attribute</a></p>
  
  <p>I want the most maintainable way of binding an enumeration and it's associated localized string values to something.  </p>
  
  <p>If I stick the enum and the class in the same file I feel somewhat safe but I have to assume there is a better way. I've also considered having the enum name be the same as the resource string name, but I'm afraid I can't always be here to enforce that.</p>
  
  <pre><code>using CR = AcmeCorp.Properties.Resources;
  
  public enum SourceFilterOption
  {
      LastNumberOccurences,
      LastNumberWeeks,
      DateRange
      // if you add to this you must update FilterOptions.GetString
  }
  
  public class FilterOptions
  {
      public Dictionary&lt;SourceFilterOption, String&gt; GetEnumWithResourceString()
      {
          var dict = new Dictionary&lt;SourceFilterOption, String&gt;();
          foreach (SourceFilterOption filter in Enum.GetValues(typeof(SourceFilterOption)))
          {
              dict.Add(filter, GetString(filter));
          }
          return dict;
      }
  
      public String GetString(SourceFilterOption option)
      {
          switch (option)
          {
              case SourceFilterOption.LastNumberOccurences:
                  return CR.LAST_NUMBER_OF_OCCURANCES;
              case SourceFilterOption.LastNumberWeeks:
                  return CR.LAST_NUMBER_OF_WEEKS;
              case SourceFilterOption.DateRange:
              default:
                  return CR.DATE_RANGE;
          }
      }
  }
  </code></pre>