委托_匿名方法<16/9/2017>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 匿名方法
{
class Program
{
static int T1(int a, int b)
{
return a + b;
}
static void Main(string[] args)
{
//修改匿名方法的形式
Func<int, int, int> plus = delegate (int a, int b)
{
return a + b;
};
Console.WriteLine(plus(1, 2));
//匿名方法 本质上是一个方法,只是没有名字,任何使用委托变量的地方都可以使用匿名方法赋值
}
}
}