I’m looking at some code that takes an IEnumerable<T> and converts it to a List<T> so it can use List<T>.Find(predicate):
var myEnumerable = ...;
var myList = new List<T>(myEnumerable);
var match = myList.Find(value => value.Aaa == aaa && value.Bbb == bbb);
Is there a way to rewrite this using the LINQ extension methods that has the same effect, but without building an extra List<T> as an intermediate step?
The FirstOrDefault(source, predicate) extension method looks like a good candidate, but trying to figure out if it’s exactly equivalent to Find is making my head hurt.
The LINQ equivelent would be to use FirstOrDefault: