I have two list of type Link
Link
{
Title;
url;
}
I have two list(List lst1 and List lst2 of type Link Now I want those element which is not in lst1 but in lst2 How can I do that using lambda expression. I dont want to use for loop.
For reference comparison:
list2.Except(list1);
For value comparison you can use:
list2.Where(el2 => !list1.Any(el1 => el1.Title == el2.Title && el1.url == el2.url));
In set operations what you are looking for is
a union minus the intersect
so (list1 union list2) except (list1 intersect list2)
check out this link for linq set operations https://msdn.microsoft.com/en-us/library/bb546153.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With