title: How to pass a generic Enum as dictionary key in method parameter
body: <p>I'm trying to create a method that counts the number of times a given Enum occurs within some existing dictionaries for reporting purposes:</p>
  
  <pre><code>private static Dictionary&lt;string, int&gt; CountEnumOccurrence(Dictionary&lt;Enum, List&lt;string&gt;&gt; valueSource)
  {
      var convertedDictionary = new Dictionary&lt;string, int&gt;();
  
      foreach (var entry in valueSource)
      {
          var name = Enum.GetName(entry.Key.GetType(), entry.Key);
          convertedDictionary.Add(name, entry.Value.Count);
      }
  
      return convertedDictionary;
  }
  </code></pre>
  
  <p>However, if I attempt to call this method like so:</p>
  
  <pre><code>var criticalFailureCounts = CountEnumOccurrence(reportSpan.criticalFailures));
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>"cannot convert from '<code>System.Collections.Generic.Dictionary&lt;Reporter.CriticalFailureCategory,System.Collections.Generic.List&lt;string&gt;&gt;</code>' to '<code>System.Collections.Generic.Dictionary&lt;System.Enum,System.Collections.Generic.List&lt;string&gt;&gt;</code>'"</p>
  </blockquote>
  
  <p>Even though Reporter.CriticalFailureCategory is an Enum. I'm obviously doing this the wrong way, but I feel like there should be some way to achieve it.</p>
  
  <p>Here's the definition for Reporter.CriticalFailureCategory at present:</p>
  
  <pre><code>namespace Reporter
  {
      [DataContract(Namespace = "")]
      public enum CriticalFailureCategory
      {
          [EnumMember]
          ExcessiveFailures,
          [EnumMember]
          StalledInConfiguration
      }
  }
  </code></pre>
  
  <p>The idea is that this can be expanded indefinitely without having to rewrite the code that reports on it.</p>