Follow

/// <summary>
        /// Follows sequence with new element
        /// </summary>
        /// <typeparam name="TSource">Source sequence element type</typeparam>
        /// <param name="sequence">Source sequence</param>
        /// <param name="value">New element value</param>
        /// <returns>Sequence with new last element</returns>
        public static IEnumerable<TSource> Follow<TSource>(this IEnumerable<TSource> sequence, TSource value)
        {
            foreach (var item in sequence)
            {
                yield return item;
            }

            yield return value;
        }
        {
            var i = 0;

            while (true)
            {
                yield return @this.AddMonths(++i * step);
            }
            // ReSharper disable once FunctionNeverReturns
        }
Example:
var list = new List<int> {1, 2, 3};

list.Follow(4);

Description

Follows sequence with new element

Details

Double click on the code to select all.

 

;