I have a list of my objects:
class MyObj { public String Title { get; set; } public Decimal Price { get; set; } public String OtherData { get; set; } } var list = new List<MyObj> { new MyObj { Title = "AAA", Price = 20, OtherData = "Z1" }, new MyObj { Title = "BBB", Price = 20, OtherData = "Z2" }, new MyObj { Title = "AAA", Price = 30, OtherData = "Z5" }, new MyObj { Title = "BBB", Price = 10, OtherData = "Z10" }, new MyObj { Title = "CCC", Price = 99, OtherData = "ZZ" } };
What is the best way to get a list with a unique name and MAX (Price). The resulting list should be:
var ret = new List<MyObj> { new MyObj { Title = "BBB", Price = 20, OtherData = "Z2" }, new MyObj { Title = "AAA", Price = 30, OtherData = "Z5" }, new MyObj { Title = "CCC", Price = 99, OtherData = "ZZ" } };
source share