Ultimately, my goal is to take two lists and then generate a third consisting of items that the first two lists do NOT share. I am able to get the results I want using two foreach
loops, but I am hoping to learn about some magical List
tool that will do it more cleanly.
public List<string> removeMatchingItems(List<string> List1, List<string> List2)
{
List<string> desiredList = new List<string>();
foreach (string value in List1)
{
if (!List2.Contains(value))
{ desiredList.Add(value); }
}
foreach (string value in List2)
{
if (!List1.Contains(value))
{ desiredList.Add(value); }
}
return desiredList;
}