Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

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

Samuel Ferree
Samuel Ferree
31,722 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

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.