title: 'An item with the same key has already been added.' -- Which key?
body: <p>The following code:</p>
  
  <pre><code>var rnd = new Random();
  Enumerable.Range(1,20).Select(x =&gt; rnd.Next(10)).ToDictionary(x =&gt; x, x =&gt; "");
  </code></pre>
  
  <p>will inevitably fail with the following exception:</p>
  
  <blockquote>
    <p><strong>System.ArgumentException</strong>: 'An item with the same key has already been added.'</p>
  </blockquote>
  
  <p>Is there any way to use the Visual Studio IDE while debugging, to find out the attempted key? Is the key stored somewhere in the exception details -- some internal / private field perhaps; which can be read using the exception details window?</p>
  
  <p>I can't change the source of <code>ToDictionary</code> to include the key in the thrown exception.</p>
  
  <p><strong>Note</strong>: I am aware that I can rewrite this in a debuggable fashion, using a <code>For Each</code> loop instead of LINQ. But I am asking about the general case -- when this exception is thrown, and the source code is not under my control, is there some way to access the key?</p>
  
  <p>Using VS 2017 Community Edition.</p>