匿名函数2

来源:互联网 发布:杭州市网络作家协会 编辑:程序博客网 时间:2024/06/06 11:47
using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks;namespace 匿名函数2{    //public delegate void MyDel();    public delegate string MyDelTwo(string msg);    public delegate int MyDel(int n1,int n2,int n3);    class Program    {        static void Main(string[] args)        {            #region 冗余代码            //List<int> list = new List<int>() { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 12, 13, 14 };            //IEnumerable<int> ies = list.Where(x => x > 5);            //foreach(var item in ies)            //{            //    Console.WriteLine(item);            //}            //Console.ReadKey();             #endregion            #region 拉姆达表达式            //MyDel mdl = ()=> { Console.WriteLine("哈哈哈"); };            //mdl();            //Console.ReadKey();             #endregion            #region 带参数的拉姆达表达式            //MyDelTwo mdt = x => x + "";            //string msg = mdt("小陆");            //Console.WriteLine(msg);            //Console.ReadKey();             #endregion            T1((x, y, z) => x + y + z);            Console.ReadKey();        }        public static void T1(MyDel add)        {            int result = add(10, 20, 30);            Console.WriteLine(result);        }    }}

0 0