title: Intersection of lists
body: <p>Is there a better, more elegant and concise, way to get the intersection of two lists in C#?</p>
  
  <p>In C# a method to calculate an intersection of list of dates is:</p>
  
  <pre><code>    public List&lt;DateTime&gt; dates_common(Timeserie ts1, Timeserie ts2)
      {
          var dt1 = new HashSet&lt;DateTime&gt;(ts1.dates);
          var dt2 = new HashSet&lt;DateTime&gt;(ts2.dates);
          dt1.IntersectWith(dt2);
          var dt = new DateTime[dt1.Count];
          dt1.CopyTo(dt);
          return new List&lt;DateTime&gt;(dt);
      }
  </code></pre>
  
  <p>In Ruby one would do this as:</p>
  
  <pre><code>def dates_common(ts1, ts2)
      dt1 = ts1.dates.to_set    
      dt2 = ts2.dates.to_set
      return dt1.intersection(dt2).to_a
  end
  </code></pre>
  
  <p>The root cause of this clunkiness is the asymmetry between IEnumerable and concrete containers and arrays. </p>
  
  <p>I am constantly amazed how badly designed C# standard libraries are as this kind of problems come up all the time.</p>
  
  <p>Is there a better, this means more elegant and concise, way to do this?</p>