标签:c style class blog code java
C#中List.ForEach 方法是对 List 的每个元素执行指定操作。
示例:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AppExample { class Program { static void Main(string[] args) { List<int> numbers = new List<int>(); numbers.Add(1); numbers.Add(2); numbers.Add(3); numbers.Add(4); numbers.Add(5); numbers.Add(6); //numbers.ForEach(Display); //numbers.ForEach(number => //{ // Console.WriteLine(number); //}); numbers.ForEach(delegate(int number) { Console.WriteLine(number); }); } static void Display(int number) { Console.WriteLine(number); } } }
C# List.ForEach 方法,布布扣,bubuko.com
标签:c style class blog code java
原文地址:http://www.cnblogs.com/libingql/p/3767510.html