This documentation is archived and is not being maintained.
List<T>::ForEach Method
Visual Studio 2010
Performs the specified action on each element of the List<T>.
Assembly: mscorlib (in mscorlib.dll)
| Exception | Condition |
|---|---|
| ArgumentNullException | action is nullptr. |
The following example demonstrates the use of the Action<T> delegate to print the contents of a List<T> object. In this example the Print method is used to display the contents of the list to the console.
Note |
|---|
In addition to displaying the contents using the Print method, the C# example demonstrates the use of anonymous methods to display the results to the console. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show:
Note