lest say I have two lists
List1:
“Tom”,
“Frank”,
“Lacey”
List2:
“Frank”,
“Tom”
what would be the query needed to show that Tom and Fran are being repeated?
The lists that I am trying to compare are very big and if I do something like:
var q = from a in List1
from b in List2
where a.Name == b.Name
select a;
this takes a long time.
To see what values are duplicated across lists, you can use
If you were otherwise interested in matching the items and doing something with each, you could use
JoinIn your case, since you are dealing with a list of strings,
Intersectseems like the appropriate course of action. If you were dealing with matching lists of objects on a common key, you might opt to join the lists and project the results.