C# Code Snippet: List.ForEach method
Do you ever use the List(T).ForEach Method in C#, if never, you’d better read this.
The syntax is :
public void ForEach(Action<T> action)
1: static void Main()
2: {
3: List<long> myList = new List<long>();
4: foreach (string item in "269, 361, 347, 355, 352, 346, 351, 354".Split(','))
5: {
6: myList.Add(long.Parse(item.Trim()));
7: }
8: myList.ForEach(FA);
9: }
10:
11: static void FA(long num)
12: {
13: Console.WriteLine(num);
14: }
Is that cool? It gives lots of convenience in coding!
