title: Select distinct by two properties in a list
body: <p>I have a <code>list&lt;message&gt;</code> that contains properties of type <code>Guid</code> and <code>DateTime</code> (as well as other properties). I would like to get rid of all of the items in that list where the <code>Guid</code> and <code>DateTime</code> are the same (except one). There will be times when those two properties will be the same as other items in the list, but the other properties will be different, so I can't just use <code>.Distinct()</code></p>
  
  <pre><code>List&lt;Message&gt; messages = GetList();
  //The list now contains many objects, it is ordered by the DateTime property
  
  messages = from p in messages.Distinct(  what goes here? ); 
  </code></pre>
  
  <p>This is what I have right now, but it seems like there ought to be a better way</p>
  
  <pre><code>List&lt;Message&gt; messages = GetList();
  
  for(int i = 0; i &lt; messages.Count() - 1)  //use Messages.Count() -1 because the last one has nothing after it to compare to
  {
      if(messages[i].id == messages[i+1}.id &amp;&amp; messages[i].date == message[i+1].date)
      {
          messages.RemoveAt(i+1);
      {
      else
      {
           i++
      }
  }
  </code></pre>