Each

/// <summary>
///     Applies an Action <typeparamref name="T"/> to all elements
///     of an array.
/// </summary>
/// <typeparam name="T">
///     Type of elements in the array
/// </typeparam>
/// <param name="elements">
///     Array of elements
/// </param>
/// <param name="action">
///     The <see cref="Action{TProperty}"/> to be performed in all
///     elements.
/// </param>
public static void Each<T>(this IEnumerable<T> elements, Action<T> action)
{
    foreach (var e in elements) action(e);
}
Example:
List<string> l = new List<string>(new[] {"hello", "world"});
l.Each( s => Console.Write(s.ToUpper() );
// Prints HELLOWORLD

Description

Iterates over all the elements in a collection and performs the given action, usually given as a lambda.

Details

Double click on the code to select all.

 

;