using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace System.Collections.Generic { public static class ExtensionMethods { public static void ForEach<T>(this IEnumerable<T> List, Action<T> Action) { foreach (T item in List) { Action.Invoke(item); } } public static void For<T>(this IEnumerable<T> List, int Start, int End, int Step, Action<T> Action) { for (int i = Start; i < End; i = i + Step) { Action.Invoke(List.ElementAt(i)); } } public static void For<T>(this IEnumerable<T> List, int Start, Func<int, bool> End, int Step, Action<T> Action) { for (int i = Start; End.Invoke(i); i = i + Step) { Action.Invoke(List.ElementAt(i)); } } public static void For<T>(this IEnumerable<T> List, int Start, Func<int, bool> End, int Step, Func<T, int, int> Action) { for (int i = Start; End.Invoke(i); i = i + Step) { i = Action.Invoke(List.ElementAt(i), i); } } } }
|