I have objects which contain a dictionary and a name (string). I want to loop through these objects, compare their dictionaries and names, and if any dictionaries & names are exact matches, I want to remove all duplicates, then return a list of objects where none of the dictionaries & names match.
Here is what I have so far:
private void removeDuplicates(List<MyObject> objectList)
{
List<Dictionary<string,string>> listOfObjDicts = new List<Dictionary<string,string>>();
List<string> nameList = new List<string>();
foreach(MyObject object in objectList)
{
nameList.Add(MyObject.name);
listOfObjDicts.Add(MyObject.dict);
}
//compare name & dictionary against all other objects, then remove any duplicates from objectList.
}
It is probably safe to assume that even this structure of a foreach loop iterating over the list of objects isn't great - because I want to return a list of objects, not a list of names and a list of dictionaries. I'm pretty stuck on this. Some people have mentioned LINQ, but I really have no experience or ability to read/understand LINQ syntax.