For Each element in an array do Action - CSharp System

CSharp examples for System:Array Element

Description

For Each element in an array do Action

Demo Code


using System;//from   ww w.  j  a v  a2  s .  co  m

public class Main{
        public static void ForEach(this Array e, Action<int> a) {
         for (int i = 0; i < e.Length; i++) {
            a(i);
         }
      }
        public static void ForEach<T>(this T[] e, Action<T, int> a) {
         for (int i = 0; i < e.Length; i++) {
            a(e[i], i);
         }
      }
}

Related Tutorials