Monday, March 28, 2016

.Find versus .Where in a Lambda in C#

IEnumerable<Foo> match = Foos.Where(item => item.Description == "Yuck");

 
 

...may be rewritten as...

Foo match = Foos.Find(item => item.Description == "Yuck");

 
 

...and doing so will make a spinning machine that stops spinning upon finding the first match.

No comments:

Post a Comment