Get different and common items in two arrays with LINQ [C#]

var list1 = new string[] {"1", "2", "3", "4", "5", "6"};
var list2 = new string[] {"2", "3", "4"};
var listCommon = list1.Intersect(list2);
foreach (string s in listCommon) Console.WriteLine(s);

Output:

2
3
4

 

http://stackoverflow.com/a/10648270

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.