匿名函数2

xiaoxiao2021-02-28  113

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); } } }
转载请注明原文地址: https://www.6miu.com/read-35213.html

最新回复(0)