开发者

Get object with minimum value using extension method min()

开发者 https://www.devze.com 2023-03-14 00:09 出处:网络
list.Min() gets me the min value as integer. I want to get the object in List whi开发者_StackOverflow社区ch has the min value for a certain property X. How can I do that?Have a look at MinBy in MoreLI

list.Min() gets me the min value as integer. I want to get the object in List whi开发者_StackOverflow社区ch has the min value for a certain property X. How can I do that?


Have a look at MinBy in MoreLINQ - or I believe Reactive Extensions has something similar in System.Interactive:

var cheapestProduct = products.MinBy(p => p.Price);

If more than one item has the lowest value, the earliest one in the sequence will be returned.

0

精彩评论

暂无评论...
验证码 换一张
取 消