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