So obviously this is easily doable with a couple of foreach loops, but I just started using C# after years of Java and now I'm trying to stuff LINQ into everything because it's so awesome.
I have two ICollections of strings, and I want to check if one collection contains any of the strings in the other one. Put another way, I want to check if the union of the two collections is empty or not.
In this case I'm not actually concerned with WHICH strings match, just whether a match exists or not. I'm assuming Any is the key method here, but I can't figure out how to do what I want with it. I'm sure the solution's pretty simple; I'm just not very familiar with building queries.
if (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