示例#1
0
 /// <summary>
 ///     Returns the minimum element of the sequence according to the specified selector - or null if the source collection
 ///     is empty or null.
 /// </summary>
 /// <remarks>
 ///     Throw ArgumentNullException if source is null
 /// </remarks>
 /// <typeparam name="TSource"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="source"></param>
 /// <param name="selector"></param>
 /// <returns></returns>
 public static TResult?MinOrNullIfNull <TSource, TResult>(this IEnumerable <TSource> source, Func <TSource, TResult> selector) where TResult : struct, IComparable
 {
     return(LinqExtensions.NullableFunctionWrapper(source, src => src.Min(selector)));
 }
示例#2
0
 /// <summary>
 ///     Returns the maximum element of the sequence according to the specified selector - or null if the source collection
 ///     is empty.
 ///     <para />
 ///     Throw ArgumentNullException if source is null
 /// </summary>
 /// <typeparam name="TSource"></typeparam>
 /// <typeparam name="TResult"></typeparam>
 /// <param name="source"></param>
 /// <param name="selector"></param>
 /// <returns></returns>
 public static TResult?MaxOrNull <TSource, TResult>(this IEnumerable <TSource> source, Func <TSource, TResult> selector) where TResult : struct, IComparable
 {
     source.CheckArgumentNull(nameof(source));
     return(LinqExtensions.NullableFunctionWrapper(source, src => src.Max(selector)));
 }