title: Use Group By in order to remove duplicates
body: <p>I am looking for a simple way of removing duplicates without having to implement the class IComparable, having to override GetHashCode etc..</p>
  
  <p>I think this can be achieved with linq. I have the class:</p>
  
  <pre><code>class Person
  {
      public string Name;
      public ing Age;
  }
  </code></pre>
  
  <p>I have a list of about 500 People <code>List&lt;Person&gt; someList = new List&lt;Person()</code></p>
  
  <p>now I want to remove people with the same name and if there is a duplicate I want to keep the person that had the greater age. In other words if I have the list:</p>
  
  <pre><code>Name----Age---
  Tom,     24  |
  Alicia,  22  |
  Alicia,  12  |
  </code></pre>
  
  <p>I will like to end up with:</p>
  
  <pre><code>Name----Age---
  Tom,     24  |
  Alicia,  22  |
  </code></pre>
  
  <p>How can I do this with a query? My list is not that long so I don't want to create a hash set nor implement the IComparable interface. It will be nice if I can do this with a linq query.</p>
  
  <p>I think this can be done with the groupBy extension method by doing something like:</p>
  
  <pre><code>var people = // the list of Person
  person.GroupBy(x=&gt;x.Name).Where(x=&gt;x.Count()&gt;1)
        ...    // select the person that has the greatest age...
  </code></pre>