IEnumerable<fishbiscuits> a = GetFishBiscuits(0);
IEnumerable<fishbiscuits> b = GetFishBiscuits(1);
if ([any of the results in either list match])
{
// Do something ie
Console.WriteLine("I see both a and b love at least one of the same type of fish biscuit!");
}
Can you use linq to see if two IEnumerables of data contain any common entries?
Yes, you can do this using Intersect
and Any
:
bool anyCommonEntries = a.Intersect(b).Any();
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