Interactive Extensions
Interactive Extensions
Ix-Main Namespaces
System.Linq
EnumerableEx Class
EnumerableEx Methods
ForEach Method
ForEach(TSource) Method (IEnumerable(TSource), Action(TSource))
ForEach(TSource) Method (IEnumerable(TSource), Action(TSource, Int32))
EnumerableEx
.
ForEach
<
TSource
>
Method (IEnumerable
<
TSource
>
, Action
<
TSource
>
)
Enumerates the sequence and invokes the given action for each value in the sequence.
Namespace:
System.Linq
Assembly:
System.Interactive (in System.Interactive.dll) Version: 1.2.0.0
Syntax
C#
Copy
public
static
void
ForEach
<TSource>(
this
IEnumerable
<TSource>
source
,
Action
<TSource>
onNext
)
Parameters
source
Type:
System.Collections.Generic
.
IEnumerable
<
TSource
>
Source sequence.
onNext
Type:
System
.
Action
<
TSource
>
Action to invoke for each element.
Type Parameters
TSource
Source sequence element type.
Usage Note
In Visual Basic and C#, you can call this method as an instance method on any object of type
IEnumerable
<
TSource
>
. 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
Reference
EnumerableEx Class
ForEach Overload
System.Linq Namespace