gpt4 book ai didi

c# - 如何对集合中所有对象的属性执行 .Max() 并返回具有最大值的对象

转载 作者:IT王子 更新时间:2023-10-29 03:28:42 25 4
gpt4 key购买 nike

<分区>

我有一个具有两个 int 属性的对象列表。该列表是另一个 linq 查询的输出。对象:

public class DimensionPair  
{
public int Height { get; set; }
public int Width { get; set; }
}

我想在列表中找到并返回具有最大 Height 属性值的对象。

我可以设法获取 Height 值的最大值,但不能获取对象本身。

我可以用 Linq 做到这一点吗?怎么办?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com