Executes an action for each element in the source collection.

Namespace: DotNetNuke.Collections
Assembly: DotNetNuke (in DotNetNuke.dll)

Syntax

C#
public static IEnumerable<TType> ForEach<TType>(
	this IEnumerable<TType> source,
	Action<TType> action
)
Visual Basic
<ExtensionAttribute> 
Public Shared Function ForEach(Of TType) ( 
	source As IEnumerable(Of TType),
	action As Action(Of TType)
) As IEnumerable(Of TType)

Parameters

source
Type: System.Collections.Generic..::..IEnumerable<(Of <(<'TType>)>)>
The source.
action
Type: System..::..Action<(Of <(<'TType>)>)>
The action.

Type Parameters

TType
The type of the type.

Return Value

returnsM:DotNetNuke.Collections.CollectionExtensions.ForEach``1(System.Collections.Generic.IEnumerable{``0},System.Action{``0})

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IEnumerable<(Of <(<'TType>)>)>. When you use instance method syntax to call this method, omit the first parameter. For more information, see [b8020aae-374d-46a9-bcb7-8cc2390b93b6] or [175ce3ff-9bbf-4e64-8421-faeb81a0bb51].

See Also