ForEach

public static void ForEach<T>(this IEnumerable<T> list, Action<T> action)
{
    foreach (var item in list)
    {
        action.Invoke(item);
    }
}
Example:
IEnumerable<User> users = GetUsers();

users.ForEach(x => x.DoSomething());

users.ForEach(x => 
{
       x.DoSomething();
       x.MagicNumber = 1;
});

Description

Foreach inline for the IEnumerable<T>.

Details

Double click on the code to select all.

 

;