Lambda Action Func练习

时间:2023-03-09 03:46:55
Lambda Action  Func练习
namespace lambda
{
delegate void TestDelegate(string s);
class Program
{
static void Main(string[] args)
{
//动态构建C# Lambda表达式例子1
var ints = new int[] {,,,,,,,,,};
var newints = ints.Where(i => i > );
foreach (var a in newints)
{
Console.WriteLine(a);
}
Array.ForEach<int>(ints, i => Console.WriteLine(i));
TestDelegate del = (s) => { string n = s + ":hello"; Console.WriteLine((n)); };
del("tom");
Action<string> ac = (s) => { Console.WriteLine(s+":hello");};
ac("action");
Func<string, string> fun = s => { return s + ":hello"; };
Console.WriteLine(fun("func"));
Func<int, string, bool> myFunc = (x, y) => (x.ToString() == y);
Console.WriteLine(myFunc(, ""));
var q = from e in ints
select new
{ test = e > ? e : -
};
foreach (var v in q)
{
Console.WriteLine(v.test);
}
Console.ReadKey();
}
}
}