title: Selecting a good dictionary key
body: <p>I have an object that I want to use to look up other objects. I will be using a <code>Dictionary&lt;TKey, TValue&gt;()</code>. </p>
  
  <p>The key object has two strings that uniquely identify it, say <code>KeyObj.Str1</code> and <code>KeyObj.Str2</code>.</p>
  
  <p>What do you recommend that I use as the key for the dictionary?</p>
  
  <p>1: The concatenation of the strings. </p>
  
  <pre><code>Dictionary&lt;String, TValue&gt;();
  Key = KeyObj.Str1:KeyObj.Str2; ("somestring:anotherstring")
  </code></pre>
  
  <p>2: A unique integer for each object to identify it?</p>
  
  <pre><code>Dictionary&lt;int, TValue&gt;();
  KeyObj.ID = _nextID++;
  Key = KeyObj.ID;
  </code></pre>
  
  <p>3: A reference to the object.</p>
  
  <pre><code>Dictionary&lt;KeyObj, TValue&gt;();
  Key = KeyObj;
  </code></pre>
  
  <p>Option 3 would be the easiest, but it seems like it would be inefficient to index a dictionary based on reference values. </p>
  
  <p>If the key object contained a single unique string, the obvious choice would be use that, but having two strings that are only unique in combination makes it more difficult.</p>