Two queries basically implement the same algorithm. Each of them will iterate c1 for each element in c2 , compare the Bar properties of two objects and return as soon as a match is found. The asymptotic complexity of both cases is the same, which means that they will scale equally well (or, if necessary, equally bad) as the size of these two sets increases. There may be slight differences between them in the overhead associated with one method over another, but the difference will not be significant, and they will be smaller and smaller as the size of the collections increases. There is no real reason to choose one of the two over the other.
There is an option that you have not shown that it is a little faster than any of them. You can use Join to find all the elements in c1 that also exist in c2 without performing a linear search in the sequence:
var query = from first in c1 join second in c2 on first.Bar equals second.Bar select first;
Another option is to use a HashSet instead of List , as it can be a lot easier to find:
var set = new HashSet<string>(c1.Select(item => item.Bar)); var query = c2.Where(item => set.Contains(item.Bar));
(This decision is pretty close to what Join will do internally.)
Both of these solutions will be much faster than any of the solutions you offer.
Servy source share