Add Repeat extension to IEnumerable
//The MIT License (MIT) //http://arolibraries.codeplex.com/license using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Reflection; using System.Text; using System.Threading; namespace AroLibraries.ExtensionMethods.Enumerable { public static class IEnumerableExt { public static IEnumerable<TResult> Ext_Repeat<TResult>(this IEnumerable<TResult> source, int count, bool onEndOfCollection) { if (count < 0) { throw new ArgumentOutOfRangeException("count"); } if (onEndOfCollection) { for (int i = 0; i < count; i++) { foreach (TResult result in source) { yield return result; } } } else { foreach (TResult result in source) { for (int i = 0; i < count; i++) { yield return result; } } } } } }