title: Create list of enums and pass it to a method
body: <p>I created a method which takes an enum and transforms it in a Dictionary where each int is associated with the name (as string) of the enum</p>
  
  <pre><code>// Define like this
  public static Dictionary&lt;int, string&gt; getDictionaryFromEnum&lt;T&gt;()
  {
     List&lt;T&gt; commandList = Enum.GetValues(typeof(T)).Cast&lt;T&gt;().ToList();
     Dictionary&lt;int, string&gt; finalList = new Dictionary&lt;int, string&gt;();
     foreach (T command in commandList)
     {
      finalList.Add((int)(object)command, command.ToString());
     }
   return finalList;
   }
  </code></pre>
  
  <p>(ps. yes, I have a double cast but the application is meant to be a very cheap-and-dirty C#-enum to Javascript-enum converter).</p>
  
  <p>This can be easily used like this</p>
  
  <pre><code>private enum _myEnum1 { one = 1001, two = 1002 };
  private enum _myEnum2 { one = 2001, two = 2002 };
  // ... 
  var a = getDictionaryFromEnum&lt;_myEnum1&gt;();
  var b = getDictionaryFromEnum&lt;_myEnum2&gt;();
  </code></pre>
  
  <p>Now, I was wondering whether I could create a list of enums to use for a series of calls to iterate my calls.</p>
  
  <p><strong>This was in the original question: [Why can't I call this?]</strong></p>
  
  <p>What should I do to be able to create a call like this one?</p>
  
  <pre><code>List&lt;Type&gt; enumsToConvertList = new List&lt;Type&gt;();
  enumsToConvertList.Add(typeof(_myEnum1));
  enumsToConvertList.Add(typeof(_myEnum2));
  // this'll be a loop
  var a = getDictionaryFromEnum&lt;enumsToConvertList.ElementAt(0)&gt;();
  </code></pre>