I have an array of classes with a property Date, i.e.:
class Record
{
public DateTime Date { get; private set; }
}
void Summarize(Record[] arr)
{
foreach (var r in arr)
{
// do stuff
}
}
I have to find the earliest (minimum) and the latest (maximum) dates in this array.
How can I do that using LINQ?
If you want to find the earliest or latest Date:
Enumerable.Min, Enumerable.Max
If you want to find the record with the earliest or latest Date:
See: How to use LINQ to select object with minimum or maximum property value