 | EnumerableExtensionsForEachT Method |
Performs the specified action on each element of the enumerable.
Namespace: Capgemini.CommonObjectUtilsAssembly: Capgemini.CommonObjectUtils (in Capgemini.CommonObjectUtils.dll) Version: 1.3.0.0
Syntaxpublic static void ForEach<T>(
this IEnumerable<T> enumerable,
Action<T> action
)
<ExtensionAttribute>
Public Shared Sub ForEach(Of T) (
enumerable As IEnumerable(Of T),
action As Action(Of T)
)
public:
[ExtensionAttribute]
generic<typename T>
static void ForEach(
IEnumerable<T>^ enumerable,
Action<T>^ action
)
static member ForEach :
enumerable : IEnumerable<'T> *
action : Action<'T> -> unit
Parameters
- enumerable
- Type: System.Collections.GenericIEnumerableT
The enumerable to act on. - action
- Type: SystemActionT
The action to take on each element.
Type Parameters
- T
- The type of elements held in the enumerable.
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).
ExamplesIEnumerable<int> myItems = ...
myItems.ForEach((x) => Console.WriteLine(x));
See Also