DEV Community

Discussion on: 5 C# Tips from a Senior Developer to Help You Program Better

Collapse
 
bsantos96 profile image
bSantos96

First of all, thank you for the fantastic article, it will be so helpful for my future developments.
I think you have committed a mistake here in MinBy section:

var cheapest = foodList.OrderBy(f => f.Price).List();
Enter fullscreen mode Exit fullscreen mode

This will return a list and not a single element, which is what we want here. It should be instead:

var cheapest = foodList.OrderBy(f => f.Price).First();
Enter fullscreen mode Exit fullscreen mode