How to Remove elements from one List based another list's element and condition?

Che*_*ara 2 c# linq c#-4.0

How to remove list items from list1 which mats condition with list2 items using LINQ without duplicates

I know how to do it in simple foreach way but i want the same using Linq style single line code.

How to do it using Linq?

Input list

list1 = new List(){new object{id = 40},new object{id = 50},new object{id = 60}}
list2 = new List(){new object{id = 400},new object{id = 50},new object{id = 600}}
Run Code Online (Sandbox Code Playgroud)

Expected Output should from list1

new object{id = 40},new object{id = 60}

Laj*_*pad 6

You can remove the elements like this:

list1.RemoveAll(item => list2.Any(item2 => item.Key == item2.Key))
Run Code Online (Sandbox Code Playgroud)