// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT License.
// See the LICENSE file in the project root for more information.
using System.Collections.Generic;
namespace System.Linq
{
public static partial class EnumerableEx
{
///
/// Generates an enumerable sequence by repeating a source sequence as long as the given loop postcondition holds.
///
/// Result sequence element type.
/// Source sequence to repeat while the condition evaluates true.
/// Loop condition.
/// Sequence generated by repeating the given sequence until the condition evaluates to false.
public static IEnumerable DoWhile(this IEnumerable source, Func condition)
{
if (source == null)
throw new ArgumentNullException(nameof(source));
if (condition == null)
throw new ArgumentNullException(nameof(condition));
return source.Concat(While(condition, source));
}
}
}