I have a list
List<MyObject> myList
and i am adding items to a list and i want to check if that object is already in the list.
so before i do this:
myList.Add(nextObject);
i want to see if nextObject is already in the list.
the object "MyObject" has a number of properties but comparison is based on matching on two properties.
what is the best way to do a check before i add a new "MyObject" to thsi list of "MyObject"s
the only solution i thought up was to change from a list to a dictionary and them make the key a concatenated string of the properties (this seems a little unelegant)
any other cleaner solutions using list or LINQ or something else?