2008-01-01

Required C# Extension Methods

Every programmer should use these simple extension methods to make their loops easier to read.


///
/// ForEach extension method for strongly typed IEnumerables
///

public static void ForEach(this IEnumerable source, Action action)
{
foreach (T item in source) action(item);
}

///
/// ForEach extension method for IEnumerables
///

public static void ForEach(this IEnumerable source, Action action)
{
foreach (T item in source) action(item);
}

0 comments: