| CollectionExtensionsForEachT Method (IEnumerableT, ActionT, Int32) |
Performs the specified action on each element of the collection, providing also the index of the item.
Namespace:
TomsToolbox.Essentials
Assembly:
TomsToolbox.Essentials (in TomsToolbox.Essentials.dll)
Syntax public static void ForEach<T>(
this IEnumerable<T> collection,
Action<T, int> action
)
<ExtensionAttribute>
Public Shared Sub ForEach(Of T) (
collection As IEnumerable(Of T),
action As Action(Of T, Integer)
)
Parameters
- collection
- Type: System.Collections.GenericIEnumerableT
The collection. - action
- Type: SystemActionT, Int32
The action.
Type Parameters
- T
- The type of elements in the collection.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerableT. When you use instance method syntax to call this method, omit the first parameter. For more information, see
Extension Methods (Visual Basic) or
Extension Methods (C# Programming Guide).
See Also