TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Thiyagarajan E
832
984
115.2k
Lambda expression vs LINQ Query Expression in c#
May 8 2019 10:16 AM
What is the difference between Lambda expression and LINQ Query expression in c#?
Please refer the below code.
// Student collection
IList<Student> studentList =
new
List<Student>() {
new
Student() { StudentID = 1, StudentName =
"John"
, Age = 13} ,
new
Student() { StudentID = 2, StudentName =
"Moin"
, Age = 21 } ,
new
Student() { StudentID = 3, StudentName =
"Bill"
, Age = 18 } ,
new
Student() { StudentID = 4, StudentName =
"Ram"
, Age = 20} ,
new
Student() { StudentID = 5, StudentName =
"Ron"
, Age = 15 }
};
// Method -1 LINQ Query Syntax to find out teenager students
var teenAgerStudent = from s
in
studentList
where s.Age > 12 && s.Age < 20
select s;
//
Method -2
Lambda expression to find out teenager students
var teenAgerStudent1 = studentList.Where(x=>x.Age > 12 && x.Age < 20).Select(x=>x).ToList();
Which is best method and why ?
Difference between method-1 and method-2?
Reply
Answers (
2
)
Automated test cases
autofetch based on combobox selection in datagridview