diff --git a/MoreLinq/Batch.cs b/MoreLinq/Batch.cs index 11187c14b..4621f46cf 100644 --- a/MoreLinq/Batch.cs +++ b/MoreLinq/Batch.cs @@ -125,7 +125,7 @@ public static IEnumerable Batch(this IEnumerable Batch(int size) { - TSource[]? bucket = new TSource[size]; + TSource[]? bucket = null; var count = 0; foreach (var item in source) @@ -139,6 +139,7 @@ IEnumerable Batch(int size) yield return resultSelector(bucket); + bucket = null; count = 0; }