Somehow you have got that result from somewhere else. (Perhaps you are writing out the contents of listDIff
first, and thought that it was from listCommon
.) The Intersect
method does give you the items that exists in both lists:
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