Lambda表达式的本质

            //.net 1.0写法
            /*delegate bool MyMethod(string s);
             bool myMethod(string s)
            {
                return s.IndexOf("abc") >= 0;
            }
            MyMethod m1 = new MyMethod(myMethod);
            
            List<string> l1 = l.FindAll(m1);
            */

            //.net 2.0 写法
            //List<string> l1 = l.FindAll(delegate(string s) { return s.IndexOf("abc")>=0; });
            //.net 3.0 写法
            List<string> l1 = l.FindAll(s=>s.IndexOf("abc") >=0);

 lambda表达式实际上是委托类型的对象

posted @ 2013-08-11 16:24  kuailewangzi1212  阅读(740)  评论(0编辑  收藏  举报