DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 964,423 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in

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