1. Anonymous Methods (匿名方法)
//example 1
delegate int MyAnonymityFunction();
private void CommonFunction()
{
MyAnonymityFunction fun = delegate
{
return 7;
}
//anonymityValue value is 7
int anonymityValue = fun();
}
//example 2
this.Button1.Click += delegate
{
//input code
}
2. Lambda Expression (Lambda表达式)
List<int> listInt = new List<int>(){1,2,3,4,5,6,7,8};
//listEven value is 2,4,6,8
List<int> listEven = listInt.FindAll(i => i%2 == 0);
-----------------------------------
悠然忆人记相思 如果觉得这篇文章对您有所帮助,请留下您的评论,谢谢.