How to find Max value of class property from Collection?

Jun 19, 2010 at 7:46 AM


I used ObservableCollection of Class Person. Person Class have property of Weight. I want to find Max Weight out of collection without using For Each loop.

How can i able to do that?



Jun 19, 2010 at 1:31 PM
Edited Jun 19, 2010 at 1:31 PM

double max = personCollection.Max(person => person.Weight);


note: expression uses System.Linq

Jun 21, 2010 at 8:02 AM

Thanks it work for me.