Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between using .First() and .Where().First()

Tags:

c#

linq

Is there any difference between this:

myList.Where(item => item == 0).First();

and this:

myList.First(item => item == 0);

The later makes far more sense to me as it is shorter, but I seem to see the top version more often.

like image 722
Cheetah Avatar asked Feb 17 '23 08:02

Cheetah


1 Answers

there is no difference other than style preference

like image 188
Jason Meckley Avatar answered Feb 18 '23 21:02

Jason Meckley