C# Querying With LINQ Querying the BirdWatcher Data Bird Search Extension

Samuel Ferree
Samuel Ferree
31,709 Points

Is join overly verbose in this instance?

It seems she uses Join, when a simple intersect would have worked just fine.

Since the point of linq is readability over performance anyways, could the teriary colors be tested thusly?

search.Colors.Intersect(s.TertiaryColors).Any()

Seems more concise to me, so I'm wondering if there's a reason she used a join, which requres more parameters

1 Answer

Luis Marsano
Luis Marsano
21,388 Points

Yes. Your more readable solution is actually efficient: LINQ defers evaluation, and .Any() short-circuits evaluation as soon as the first element in the intersection is found.