Linq 演变的过程(delegate => Lamb => Linq)

演变的过程(delegate => Lamb => Linq)
1.
Func
<string,bool> filter = delegate(string s){
                            
return s.Length == 5;}
;
Func
<string,string> extract = delegate(string s){
                            
return s;}

Func
<string,string> project = delegate(string s){
                            
return s.ToUpper();}


IEnumerable
<string> query = names
                            .where(filter)
                            .orderby(extract)
                            .select(project);
2.
IEnumerable
<string> query = names
                            .where(s 
=> s.Length ==5)
                            .orderby(s 
=> s)
                            .select(s 
=> s.ToUpper())

3.
IEnumerable
<string> query = from s in names
                            where s.Length 
==5
                            orderby s
                            select s.ToUpper();
了解了代码的演变,有助于对linq有一个初步认识.
posted @ 2007-06-15 16:07  RicoRui  阅读(802)  评论(1编辑  收藏  举报