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
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()); }