title: Getting Keys and Values from IEnumerable<Dictionary<string, object>>
body: <p>I have a <code> IEnumerable &lt; Dictionary &lt; string, object > > </code> object.</p>
  
  <p>I want to get the "aaavalue" "bbbvalue" "cccvalue" "dddvalue" in a array.</p>
  
  <p>Sample Data:</p>
  
  <pre><code>IEnumerable&lt;Dictionary&lt;string, object&gt;&gt; testData = new IEnumerable&lt;Dictionary&lt;string, object&gt;&gt;();
  
  /* Values in testData will be like
     [0] - 
           aaa - aaaValue   (Key, Value)
           bbb - bbbValue
           ccc - cccValue
           ddd - dddValue  
     [1] - 
           aaa - aaaValue   (Key, Value)
           bbb - bbbValue
           ccc - cccValue
           ddd - dddValue  
  
      and so on */
  </code></pre>
  
  <p>I know it is possible using Reflection or LINQ. But I could not able to make it up.</p>
  
  <p>Please help..</p>
  
  <p><strong>Answer:</strong></p>
  
  <pre><code>IEnumerable&lt;Dictionary&lt;string, object&gt;&gt; enumerable = testData as List&lt;Dictionary&lt;string, object&gt;&gt; ?? testData .ToList();
  foreach (Dictionary&lt;string, object&gt; objects in enumerable)
  {
      IEnumerable&lt;object&gt; values = objects.Select(x =&gt; x.Value); // To get the values.
      IEnumerable&lt;string&gt; keys = objects.Select(x =&gt; x.Key); // To get the keys.
  }
  </code></pre>