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
foreach(var agent in Agents) { if(Agents.Count(a => a.ID == agent.ID) > 1) Console.WriteLine("Found: {0}", agent.ID); }