title: How to retrieve actual item from HashSet<T>?
body: <p>I've read <a href="https://stackoverflow.com/questions/1494812/why-cant-i-retrieve-an-item-from-a-hashset-without-enumeration">this question</a> about why it is not possible, but haven't found a solution to the problem.</p>
  
  <p>I would like to retrieve an item from a .NET <a href="http://msdn.microsoft.com/en-us/library/bb359438.aspx" rel="noreferrer"><code>HashSet&lt;T&gt;</code></a>. I'm looking for a method that would have this signature:</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Determines if this set contains an item equal to &lt;paramref name="item"/&gt;, 
  /// according to the comparison mechanism that was used when the set was created. 
  /// The set is not changed. If the set does contain an item equal to 
  /// &lt;paramref name="item"/&gt;, then the item from the set is returned.
  /// &lt;/summary&gt;
  bool TryGetItem&lt;T&gt;(T item, out T foundItem);
  </code></pre>
  
  <p>Searching the set for an item with such a method would be O(1). The only way to retrieve an item from a <code>HashSet&lt;T&gt;</code> is to enumerate all items which is O(n).</p>
  
  <p>I haven't find any workaround to this problem other then making my own <code>HashSet&lt;T&gt;</code> or use a <code>Dictionary&lt;K, V&gt;</code>. Any other idea?</p>
  
  <p><strong>Note:</strong><br>
  I don't want to check if the <code>HashSet&lt;T&gt;</code> contains the item. I want to get the reference to the item that is stored in the <code>HashSet&lt;T&gt;</code> because I need to update it (without replacing it by another instance). The item I would pass to the <code>TryGetItem</code> would be equal (according to the comparison mechanism that I've passed to the constructor) but it would not be the same reference.</p>