c# - Create New List From Existing Lists Comparison -
i have 2 lists:
list<course> studentcourses = course.getcourses(student.pidm, gettermcode()); list<offeredcourse> offeredcourses = offeredcourse.getofferedcourses();
studentcourses have properties subjectcode
, coursenumber
.
offeredcourses have properties subjectcode
, coursenumber
.
i want create third list of type list<course>
contains items studentcourses
match both subjectcode
, coursenumber
of item in offeredcourses
.
any appreciated.
linq uses non-intuitive syntax that: use contains
collection might contain values you're after.
var result = studentcourses.where(c => offeredcourses.contains(o => o.subjectcode == c.subjectcode && o.coursenumber == c.coursenumber));
Comments
Post a Comment