/// <summary> /// Performs the specified action on each element /// </summary> /// <typeparam name="T">The type of the elements</typeparam> /// <param name="elements">The elements to perform the action on</param> /// <param name="action">The action to perform on each element</param> public static void ForEach <T>(this IEnumerable <T> elements, Action <T> action) { ExceptionUtilities.CheckArgumentNotNull(elements, "elements"); ExceptionUtilities.CheckArgumentNotNull(action, "action"); var list = elements as List <T>; if (list != null) { #if WIN8 PlatformHelper.ForEach(list, action); #else list.ForEach(action); #endif } else { foreach (var element in elements) { action(element); } } }