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 4.6K  
How about using Linq to find the common items in a list?List listOne = new List{a, b, c, d};List listTwo = new List { d, e, f, g };List listCommon= listOne.Intersect(listTwo).ToList();
How about using Linq to find the common items in a list?

XML
List<String> listOne = new List<string>{"a", "b", "c", "d"};
List<String> listTwo = new List<string> { "d", "e", "f", "g" };
List<String> listCommon= listOne.Intersect(listTwo).ToList();

License

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