I have a class Agent with a property Id
Given a collection of Agents I need to check if any of them have duplicate Ids.
I am currently doing this with a hash table but am trying to get Linq-ified, what's a good way of doing this?
Similar to Y Low's approach,
Edited:
var duplicates = agents.GroupBy(a => a.ID).Where(a=>a.Count() > 1);
foreach (var agent in duplicates)
{
Console.WriteLine(agent.Key.ToString());
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With