C# LIST.FOREACH +lambda example

never found a really simple example, see this:
List<string> parts = new List<string>();
parts.ForEach(delegate (string p) {
     Console.WriteLine(p);    });
since in lambda () is delegate() so
List<DateTime> dates = new List<DateTime>(); // just to show that T doesnt matter
parts.ForEach((DateTime d) =>
{
      Console.WriteLine(d);
});
PLUS u can do the remarkable list.Remove(d)! unlike foreach

Comments

Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

SOLVED The item could not be indexed successfully because the item failed in the indexing subsystem

JS/JQ simulate Enter event