How to perform .Max() on a property of all objects in a collection and return the object with maximum value [duplicate]

I have a list of objects that have two int properties. The list is the output of another linq query. The object:

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

I want to find and return the object in the list which has the largest Height property value.

I can manage to get the highest value of the Height value but not the object itself.

Can I do this with Linq? How?

9 Answers
9

Leave a Comment