Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C#

Diff two lists

5.00/5 (1 vote)
21 Dec 2010CPOL 5.4K  
I also updated the one easy way to remove duplicate element from two liststatic List removeDuplicates(List la){ Dictionary uniqueStore = new Dictionary(); List finalList = new List(); foreach (string currValue in...
I also updated the one easy way to remove duplicate element from two list

XML
static List<string> removeDuplicates(List<string> la)
{
    Dictionary<string, int> uniqueStore = new Dictionary<string, int>();
    List<string> finalList = new List<string>();
    foreach (string currValue in la)
    {
        if (!uniqueStore.ContainsKey(currValue))
        {
            uniqueStore.Add(currValue, 0);
            finalList.Add(currValue);
        }
    }
    return finalList;
}

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)