This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static TSource MaxOrDefault<TSource>(this IEnumerable<TSource> source) | |
where TSource : IComparable | |
{ | |
return source.MaxOrDefault(default(TSource)); | |
} | |
public static TSource MaxOrDefault<TSource>(this IEnumerable<TSource> source, TSource defaultValue) | |
where TSource : IComparable | |
{ | |
return source.Aggregate(defaultValue, (a, b) => a != null && a.CompareTo(b) > 0 ? a : b); |