lets say I have a list of strings:
A,B,C,D
Then another list of strings
B,C,D
I want to know what elements are in the first list that aren't in the second list, so the result would be A
I don't know the name of the extension method to do this is. I know I can use concat, union, intersect for similar list comparisons, but just don't know the name to accomplish this particular task.
Addendum, I am interested in duplicates, so if the first list is:
A,A,A,B,C,D
and the second list is
B,C,D
i want to get
A,A,A
Thanks!
You can use the Except Extension Method to get all elements in a list that are not in a second list:
var result = list1.Except(list2);
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