C#: Check if arrays contain any similar item

Following code can be used to check if two arrays contain any similar item or not:


string[] allLocations = { "New York", "London", "Washington", "India", "Pakistan"};
            string[] mainUSlocations = { "Boston", "Los Angels", "New York" };
            if (allLocations.ToList().Any(al => mainUSlocations.Contains(al)))
            {
                //Yor logic goes here
            }




profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+