I see that over on this question LINQy way to check if any objects in a collection have the same property value there is a request to say how to do something using LINQ to see if a property matches in a collection. However, is this the fastest reasonable process by which to do this? I will be deploying something that requires a certain amount of resource management, and I want the application to be as responsive as can be, without making the code terribly hard to decipher when someone else, or myself come back to it later.
Share
I’d guess that a fast way (perhaps the fastest way) to do it might be to add all the objects into a Dictionary or a HashSet, using the property as the key field: a method like HashSet.Add has a return code which tells you whether this property value has already been added. For example: