C# lamda表达式
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace lamda表达式 { public delegate void DeleOne(); public delegate void DeleTwo(string name); public delegate string DeleThree(string name); class Program { static void Main(string[] args) { //1 匿名函数 //DeleOne dele1 = delegate(){}; //DeleTwo dele2 = delegate(string name) { }; //DeleThree dele3 = delegate(string name) { return name; }; //lamda表达式中的委托 DeleOne dele1 = () => { }; DeleTwo dele2 = (string name) => { }; DeleThree dele3 = (string name) => { return name; }; List<int> list = new List<int>() { 1, 2, 3, 6, 3, 5, 7 }; //表示n所满足的条件 list.RemoveAll(n => n > 4); foreach(var item in list) { Console.WriteLine(item); } } } }