title: How to use an object's identity as key for Dictionary<K,V>
body: <p>Is it possible to use an object as a key for a <code>Dictonary&lt;object, ...&gt;</code> in such a way that the Dictionary treats objects as equal only if they are identical?</p>
  
  <p>For example, in the code below, I want Line 2 to return 11 instead of 12:</p>
  
  <pre><code>Dictionary&lt;object, int&gt; dict = new Dictionary&lt;object, int&gt;();
  object a = new Uri("http://www.google.com");
  object b = new Uri("http://www.google.com");
  
  dict[a] = 11;
  dict[b] = 12;
  
  Console.WriteLine(a == b);  // Line 1. Returns False, because a and b are different objects.
  Console.WriteLine(dict[a]); // Line 2. Returns 12
  Console.WriteLine(dict[b]); // Line 3. Returns 12
  </code></pre>
  
  <p>The current Dictionary implementation uses <code>object.Equals()</code> and <code>object.GetHashCode()</code> on the keys; but I am looking for a different kind of dictionary that uses the object's <strong>identity</strong> as a key (instead of the object's value). Is there such a Dictionary in .NET or do I have to implement it from scratch?</p>