title: Recreating a Dictionary from an IEnumerable<KeyValuePair<>>
body: <p>I have a method that returns an <code>IEnumerable&lt;KeyValuePair&lt;string, ArrayList&gt;&gt;</code>, but some of the callers require the result of the method to be a dictionary. How can I convert the <code>IEnumerable&lt;KeyValuePair&lt;string, ArrayList&gt;&gt;</code> into a <code>Dictionary&lt;string, ArrayList&gt;</code> so that I can use <code>TryGetValue</code>?</p>
  
  <p>method:</p>
  
  <pre><code>public IEnumerable&lt;KeyValuePair&lt;string, ArrayList&gt;&gt; GetComponents()
  {
    // ...
    yield return new KeyValuePair&lt;string, ArrayList&gt;(t.Name, controlInformation);
  }
  </code></pre>
  
  <p>caller:</p>
  
  <pre><code>Dictionary&lt;string, ArrayList&gt; actual = target.GetComponents();
  actual.ContainsKey("something");
  </code></pre>