Performs the specified action on each element of the . The type of the elements of the input sequence. The sequence of elements to execute the . The delegate to perform on each element of the <see cref="IEnumerable{T}
(this IEnumerable<T> source, Action<T> action)
| 146 | /// <param name="action">The <see cref="Action{T}"/> delegate to perform on each element of the <see cref="IEnumerable{T}"/>1.</param> |
| 147 | /// <exception cref="ArgumentException"><paramref name="source"/> or <paramref name="action"/> is <see langword="null"/>.</exception> |
| 148 | public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) |
| 149 | { |
| 150 | if (source == null) |
| 151 | throw new ArgumentNullException(nameof(source)); |
| 152 | if (action == null) |
| 153 | throw new ArgumentNullException(nameof(action)); |
| 154 | foreach (var item in source) |
| 155 | { |
| 156 | action(item); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | /// <summary> |
| 161 | /// Chooses a random item from the collection. |
no outgoing calls
no test coverage detected