Click here to Skip to main content
15,879,096 members
Articles / Programming Languages / C#
Alternative
Tip/Trick

Diff two lists

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
21 Dec 2010CPOL 4.5K   1  
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)


Written By
Software Developer (Senior) realdolmen
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
-- There are no messages in this forum --