title: How do you get the duplicate key that ToDictionary() has failed on?
body: <p>I'm creating a Dictionary object, using <code>IEnumerable</code>'s <code>ToDictionary()</code> extension method:</p>
  
  <pre><code>var dictionary = new Dictionary&lt;string, MyType&gt;
      (myCollection.ToDictionary&lt;MyType, string&gt;(k =&gt; k.Key));
  </code></pre>
  
  <p>When it executes, it throws the following <code>ArgumentException</code>:</p>
  
  <blockquote>
    <p>An item with the same key has already been added.</p>
  </blockquote>
  
  <p>How do I get it to tell me what the duplicate key is?</p>