CSharp examples for System.Collections:IEnumerable
Perform a specified action on every element of an collection.
using System.Text; using System.Linq; using System.Collections.Generic; using System;//www.j a v a 2 s . c om public class Main{ /// <summary> /// Perform a specified action on every element of an collection. /// <param name="source">An IEnumerable<T> collection in which the iteration is performed.</param> /// <param name="func">The action to be performed.</param> /// </summary> public static void ForEach<T>(this IEnumerable<T> source, Action<T> func) { foreach (T elem in source) { func(elem); } } }