From the list of objects containing the following information (id, name, address, code):
1,Andrea,15th St,123
2,Sarah,15th St,124
3,Andrea,15th St,134
4,Andrea,16th St,124
I want to get strings with the same name and address, but with a different code. In this example:
1,Andrea,15th St,123
3,Andrea,15th St,134
I went about it with Linq, learning about it for the first time. I managed to find duplicates:
var sameEmail =
from l in list
group l by new { l.name, l.address} into na
where na.Count() > 1
select na.Key;
But I can’t find a way to make sure that I only get records with different codes. I would also get the last line, but since it has the same code, I don't want this. Is there any way to do this with Linq? Or any other way in C #?
Thanks!