Click here to Skip to main content
16,021,580 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Replacing foreach loop with LINQ

Rate me:
Please Sign up or sign in to vote.
4.38/5 (5 votes)
22 Oct 2011CPOL 15.3K   2
Isn't it possible to remove the from and select statements by using a lambda expression?var bestStudents=students.Where(s=>s.Grade>9);
Isn't it possible to remove the from and select statements by using a lambda expression?
var bestStudents=students.Where(s=>s.Grade>9);

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Student
Wales Wales
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralReason for my vote of 2 Possible but (to some of us) not pre... Pin
dmjm-h1-Nov-11 5:40
dmjm-h1-Nov-11 5:40 
Reason for my vote of 2
Possible but (to some of us) not preferable.
GeneralReason for my vote of 4 Optimized the code and reduced the e... Pin
Praveen Raghuvanshi22-Oct-11 22:59
professionalPraveen Raghuvanshi22-Oct-11 22:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.