You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
528 B

4 years ago
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. public static class IEnumeratorExtensions
  5. {
  6. /// <summary>
  7. /// Loops through all items in a a collection and applies an action to them
  8. /// </summary>
  9. /// <param name="collection">collection to loop through</param>
  10. /// <param name="action">Action to apply</param>
  11. public static void ForEach<T>(this IEnumerable<T> collection, Action<T> action)
  12. {
  13. foreach (var item in collection)
  14. action(item);
  15. }
  16. }