Immediately executes the given action on each element in the source sequence.
Declaration Syntax
C# | Visual Basic | Visual C++ |
public static void ForEach<T>( this IEnumerable<T> source, Action<T> action )
<ExtensionAttribute> _ Public Shared Sub ForEach(Of T) ( _ source As IEnumerable(Of T), _ action As Action(Of T) _ )
public: [ExtensionAttribute] generic<typename T> static void ForEach( IEnumerable<T>^ source, Action<T>^ action )
Generic Template Parameters
- T
- The type of the elements in the sequence
Parameters
- source (IEnumerable<(Of <(<'T>)>)>)
- The sequence of elements
- action (Action<(Of <(<'T>)>)>)
- The action to execute on each element
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'T>)>)>. When you use instance method syntax to call this method, omit the first parameter.
Assembly: MoreLinq (Module: MoreLinq.dll) Version: 1.0.16006.0 (1.0.16006.1845)