Suppose you have a list of strings – a nursery rhyme may be a good example.  And you need to find ALL the words that match from another list of words.

Using LINQ to search a list for items in another list (should return a collection of all the matching words – “The,”, “Mouse”,”Up”

        var rhyme = "The mouse ran up the clock";
        private string[] wordsToSearchFor =
        {
            "The","mouse","up"
        };

        public IQueryable<string> FindWordsInRhyme()
        {

            var wordsFoundInRhyme = rhyme.Where(a => wordsToSearchFor.Count(i => a.ToString().Contains(i)) == 0);
            return wordsFoundInRhyme;
        }

Anuj holds professional certifications in Google Cloud, AWS as well as certifications in Docker and App Performance Tools such as New Relic. He specializes in Cloud Security, Data Encryption and Container Technologies.

Initial Consultation

Anuj Varma – who has written posts on Anuj Varma, Hands-On Technology Architect, Clean Air Activist.