Skip to content

Commit bbbfc04

Browse files
rameelandrewvk
authored andcommitted
Fixed bugs in generic MinByOrDefault / MaxByOrDefault
1 parent 98cdd92 commit bbbfc04

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Main/src/Collections/EnumerableExtensions.MinMaxBy.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public static TSource MinByOrDefault<TSource, TValue>(
4545
[NotNull, InstantHandle] this IEnumerable<TSource> source,
4646
[NotNull, InstantHandle] Func<TSource, TValue> selector,
4747
TSource defaultValue = default(TSource)) =>
48-
MinByOrDefault(source, selector, Comparer<TValue>.Default);
48+
MinByOrDefault(source, selector, Comparer<TValue>.Default, defaultValue);
4949

5050
/// <summary>
5151
/// Invokes a <paramref name="selector"/> on each element of a <paramref name="source"/>
@@ -178,7 +178,7 @@ public static TSource MinByOrDefault<TSource, TValue>(
178178
using (var e = source.GetEnumerator())
179179
{
180180
if (!e.MoveNext())
181-
return default(TSource);
181+
return defaultValue;
182182

183183
value = selector(e.Current);
184184
item = e.Current;
@@ -363,7 +363,7 @@ public static TSource MaxByOrDefault<TSource, TValue>(
363363
using (var e = source.GetEnumerator())
364364
{
365365
if (!e.MoveNext())
366-
return default(TSource);
366+
return defaultValue;
367367

368368
value = selector(e.Current);
369369
item = e.Current;

0 commit comments

Comments
 (0)