Mega Code Archive

 
Categories / C# / Collections Data Structure
 

Performs the specified action on each element of the ListT

using System; using System.Collections.Generic; class Program {     static void Main()     {         List<String> names = new List<String>();         names.Add("B");         names.Add("A");         names.Add("R");         names.ForEach(Print);         names.ForEach(delegate(String name)         {             Console.WriteLine(name);         });     }     private static void Print(string s)     {         Console.WriteLine(s);     } }