MSDN says the List.ForEach method will "perform the specified action on each element of the List".
The following program does print out a haiku to the console, but does not make the haiku all lowercase.
using System;
using System.Collections.Generic;
class WWWTC
{
static void Main()
{
List<string> haiku = new List<string>();
haiku.Add("All software changes");
haiku.Add("Upon further reflection -");
haiku.Add("A reference to String");
// make it lowercase
haiku.ForEach(
delegate(string s)
{
s = s.ToLower();
}
);
// ... and now print it out
haiku.ForEach(
delegate(string s)
{
Console.WriteLine(s);
}
);
}
}
What's wrong?