4

list.Min() 将最小值作为整数获取。我想在 List 中获取某个属性 X 的最小值的对象。我该怎么做?

4

1 回答 1

11

看看MinByMoreLINQ - 或者我相信 Reactive Extensions 有类似的东西System.Interactive

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

如果不止一项具有最低值,则将返回序列中最早的一项。

于 2011-06-20T15:58:27.070 回答