Chain

public static T Chain<T>(this T source, Action<T> action)
{
    action(source);
    return source;
}
Example:
var l = new Collection<SelectListItem>{
 new SelectListItem{ Text="t0", Value="y0" },
 new SelectListItem{ Text="t1", Value="y1" },
 new SelectListItem{ Text="t2", Value="y2" },
 new SelectListItem{ Text="t2", Value="y3" },
}.Chain(o => o.ForEachYield(m => m.Selected = (m.Value == "y3")));

Description

Allows chaining together actions to be taken place on the fly. It works with any object. Its a simple concept but I couldn't find any examples that does the same.

Details

Double click on the code to select all.

 

;