LINQ to Object comparing two lists of integer for different values
I accept both C# and VB.NET suggestion, even though I'm writing an app in VB.NET
I have two lists of intergers
- 开发者_如何学编程List1 {1,2,3,5}
- List2 {2,4,6,7}
I want to have new List3 {4,6,7} which is composed of elements of List2 that are not in List1. I know I can write a nice For Each loop for this but I want it done in LINQ I've been looking for such methods at Enumerable Methods, but I can't find it.
Is there any way to do with LINQ?
List2.Except(List1)
var List3 = List2.Except(List1);
精彩评论