I would recommend that the two lists are stored in Dictionary<string, Employee> based on the name to start with, then you can iterate over the keys in one and look if they exist, and the salaries match in the other. It will also save the cost of sorting them later or add them to a more efficient structure.
It is pretty much O (n) - linear to build both dictionaries, linear to go through the keys and search in the other. Since O (n + m + n) reduces to O (n)
But , if you should use List<T> to store lists for other reasons, you can also use the LINQ Join() method and create a new list with a Match field that tells you whether they were a match or a mismatch ...
var results = newEmpList.Join( oldEmpList, n => n.Name, o => o.Name, (n, o) => new { Name = n.Name, Salary = n.Salary, Match = o.Salary == n.Salary });
You can then filter this out using the Where() clause for Match or !Match .
source share