If your intention is not what John describes, but more, to compare the list of names with the list of student names and find the differences:
var invalidStudents = names.Zip(stud, (name, student) => new {name, student}). Where(item => (item.name != item.student.Name)); if (invalidStudents.Any())
eg:
var names = new string[] { "John", "Mary" }; var stud = new Student[] { new Student(1, "John", "IT"), new Student(2, "Jack", "Math") }; var invalidStudents = names.Zip(stud, (name, student) => new {name, student}). Where(item => (item.name != item.student.Name)); foreach (var item in invalidStudents) { Console.WriteLine(item.name); }
Gotta write mary
vc 74 source share