title: In C# how do I get a list of the keys from a dictionary?
body: <p>I have the following code:</p>
  
  <pre><code>Dictionary &lt;string, decimal&gt; inventory;
  // this is passed in as a parameter.  It is a map of name to price
  // I want to get a list of the keys.
  // I THOUGHT I could just do:
  
  List&lt;string&gt; inventoryList = inventory.Keys.ToList();
  </code></pre>
  
  <p>But I get the following error:</p>
  
  <blockquote>
    <p>'System.Collections.Generic.Dictionary.KeyCollection'
    does not contain a definition for 'ToList' and no extension method
    'ToList' accepting a first argument of type
    'System.Collections.Generic.Dictionary.KeyCollection'
    could be found (are you missing a using directive or an assembly
    reference?)</p>
  </blockquote>
  
  <p>Am I missing a using directive?  Is there something other than </p>
  
  <pre><code>using System.Collections.Generic;
  </code></pre>
  
  <p>that I need?</p>
  
  <p>EDIT</p>
  
  <pre><code>List &lt; string&gt; inventoryList = new List&lt;string&gt;(inventory.Keys);
  </code></pre>
  
  <p>works, but just got a comment regarding LINQ</p>