title: C# List of different object types: Better way than Zip to check equality
body: <p>I have code that works right now, effectively performing the elementwise comparison in the lambda for Linq's Zip extension method, then checking for any failed matches, but I'm nearly certain there must be a more concise and readable way of accomplishing the same thing.</p>
  <p>I know I could implement an EqualityComparer and use SequenceEqual, but I dislike the overhead of that solution for one-off list comparisons like this one. I'm willing to accept that an EqualityComparer is the <em>correct</em> solution, but if there are alternatives, I'd love to see them.</p>
  <pre><code>class Occurrence {
      DateTime Start;
      // More fields...
  }
  
  bool SameDates(List&lt;Occurrence&gt; occurrences, List&lt;DateTime&gt; selectedDates)
  {
      if (occurrences.Count != selectedDates.Count)
              return false;
  
      // These three lines are the focus of the question
      var dateEqualList = occurrences.Zip(selectedDates, (a, b) =&gt; a.Start.Date == b.Date);
      if (dateEqualList.Contains(false))
          return false;
  
      return true;
  }
  
  </code></pre>