演变的过程(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有一个初步认识.
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();