I have an IEnumerable containing objects that have a groupnumber property. I want to be able to get a list of all objects that have duplicate groupnumbers e.g.
obj1: groupnumber=1 KEEP
obj2: groupnumber=2 DELETE
obj3: groupnumber=1 KEEP
I can use the following to get a list of all the duplicated groupnumbers
var duplicates = from c in sorted
group c by c.groupnumber into g
where g.Count() > 1
select new { groupnumber = g.Key, recs = g.Count() };
but I cant figure out how to get a list cleaned of all the single instance objects
Cheers