Based on your
ListExtensions
class I've created a slightly modified one:public static class ListExtensions
{
public static void forEach<T>(this IEnumerable<T> list, dynamic function)
{
list.ToList().ForEach(item => function(item));
}
}
This mimics the JavaScript forEach
function for native arrays (at least to some degree) and in addition works both for .NET lists and .NET arrays.