Advertisement
Hydr0ph0bia

Enumerable Extensions

Nov 17th, 2017
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.47 KB | None | 0 0
  1. public static class EnumerableExtensions{
  2.   public static int ForEach<T>(this IEnumerable<T> input, Action<T> toRunAct)
  3.         {
  4.             int iterations = 0;
  5.             if (input == null) return iterations;
  6.             foreach (var put in input)
  7.             {
  8.                 if (!put.Equals(default(T)))
  9.                 {
  10.                     toRunAct(put);
  11.                     iterations++;
  12.                 }
  13.             }
  14.             return iterations;
  15.         }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement