LINQ和委托随意转化例子参考

static void Main(string[] args)
{


//LINQ简化

Action<string> f1 = s =>
Console.WriteLine(s);

//委托
Action<string> f11 = delegate (string s)
{
Console.WriteLine(s);
};

//LINQ简化

Func<int, bool> f2 = i => i > 5;

//委托
Func<int, bool> f3 = delegate (int i)
{
return i > 5;
};

f1("123");
f11("1234");
f2(4);

 

posted @ 2022-08-26 16:24  NangFah  阅读(25)  评论(0)    收藏  举报