Getting differences between collections in LINQ

Posted by dotnetdev on Stack Overflow See other posts from Stack Overflow or by dotnetdev
Published on 2010-04-06T15:54:23Z Indexed on 2010/04/06 16:03 UTC
Read the original article Hit count: 154

Filed under:
|

Hi,

I have a collection of image paths, and a larger collection of Image objects (Which contain a path property). I have the code to check for any matching images, but if there are supposed to be four matching image paths (as that is how many are in the first collection), and there is less than this, how can I get the missing one without writing loops?

        List<string> ImagesToCheck = new List<string>()
        {
            "",
            "s",
            "ssdd"
        };

        IEnumerable<HtmlImage> Images = manager.ActiveBrowser.Find.AllControls<HtmlImage>();

        var v = from i in Images
                where ImagesToCheck.Any(x => x == i.Src)
                select i;

        if (v.Count() < 3)
        {

        }

So I need to get the items which are not in the collection titled v, but are in ImagesToCheck.

How could I do this with LINQ?

Thanks

© Stack Overflow or respective owner

Related posts about c#

Related posts about LINQ