title: How to implement IComparer in C# for an interface
body: <p>I have an interface named <code>IEmployee</code>. I need to implement the IComparer to the implementation of my interface.</p>
  
  <p>Here is my code,</p>
  
  <pre><code>interface IEmployee
    {
  
        String Name {get;set;}
        DateTime DOB {get;set;}
    }
  </code></pre>
  
  <p>I have created a child class for this like</p>
  
  <pre><code>class Employee
    {
  
        String Name {get;set;}
        DateTime DOB {get;set;}
    }
  </code></pre>
  
  <p>Now i need to implement the IComparer to this, and in my <code>Main</code> i want to get the copmarer like</p>
  
  <pre><code>IComparer&lt;IEmployee&gt; comparerobject= // The comparer from the class.
  </code></pre>
  
  <p>And using this <code>comparer</code> i need to sort the collection of <code>employee</code> based on their names, like</p>
  
  <pre><code>var employees = new IEmployee[]{new Employee("....."),....}
  Array.Sort&lt;IEmployee&gt;(employees , comparer);
  </code></pre>