title: How to use Comparer for a HashSet
body: <p>As a result of another question I asked here I want to use a HashSet for my objects </p>
  
  <p>I will create objects containing a string and a reference to its owner. </p>
  
  <pre><code>public class Synonym
  {
     private string name;
     private Stock owner;
     public Stock(string NameSynonym, Stock stock)
     {
         name=NameSynonym;
         owner=stock
     }
     // [+ 'get' for 'name' and 'owner']
  }
  </code></pre>
  
  <p>I understand I need a comparer , but never used it before.  Should I create a separate class?  like:</p>
  
  <pre><code>public class SynonymComparer : IComparer&lt;Synonym&gt;
  {
     public int Compare(Synonym One, Synonym Two)
     { // Should I test if 'One == null'  or  'Two == null'  ???? 
         return String.Compare(One.Name, Two.Name, true); // Caseinsesitive
     }
  </code></pre>
  
  <p>}</p>
  
  <p>I prefer to have a function (or nested class [maybe a singleton?] if required) being PART of class Synonym instead of another (independent) class. Is this possible?</p>
  
  <p>About usage:
  As i never used this kind of thing before I suppose I must write a Find(string NameSynonym) function inside class Synonym, but how should I do that?</p>
  
  <pre><code>public class SynonymManager
  { 
      private HashSet&lt;SynonymComparer&lt;Synonym&gt;&gt; ListOfSynonyms;
  
      public SynonymManager()
      {
          ListOfSymnonyms = new HashSet&lt;SynonymComparer&lt;Synonym&gt;&gt;();
      }
  
      public void SomeFunction()
      { // Just a function to add 2 sysnonyms to 1 stock
          Stock stock = GetStock("General Motors");
          Synonym otherName = new Synonym("GM", stock);
          ListOfSynonyms.Add(otherName);
          Synonym otherName = new Synonym("Gen. Motors", stock);
          ListOfSynonyms.Add(otherName);
      }
  
      public Synonym Find(string NameSynomym)
      {
         return ListOfSynonyms.??????(NameSynonym);
      }
   }
  </code></pre>
  
  <p>In the code above I don't know how to implement the 'Find' method. How should i do that?</p>
  
  <p>Any help will be appreciated
  (PS If my ideas about how it should be implemented are completely wrong let me know and tell me how to implement)</p>