using System.Collections.Generic;
public static void Main()
IList<Student> studentList = new List<Student>() {
new Student() { StudentID = 1, StudentName = "John", Age = 13} ,
new Student() { StudentID = 3, StudentName = "Bill", Age = 18 } ,
new Student() { StudentID = 5, StudentName = "Ron" , Age = 15 }
IList<Student> studentList2 = new List<Student>() {
new Student() { StudentID = 1, StudentName = "John", Age = 13} ,
new Student() { StudentID = 2, StudentName = "Moin", Age = 21 } ,
new Student() { StudentID = 5, StudentName = "Ron" , Age = 15 }
var commonStudents = studentList.Select(x => x.StudentName).ToList().Intersect(studentList2.Select(y => y.StudentName)).ToList();
Console.WriteLine("Common Students:");
foreach(var student in commonStudents){
Console.WriteLine(student);
var nonMatchStudents = studentList.Select(x => x.StudentName).ToList().Concat(studentList2.Select(y => y.StudentName)).ToList();
Console.WriteLine("Except Students:");
foreach(var student in nonMatchStudents){
Console.WriteLine(student);
public int StudentID { get; set; }
public string StudentName { get; set; }
public int Age { get; set; }