演变的过程(
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();
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();