Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8454911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:08:56+00:00 2026-06-10T12:08:56+00:00

This should be simple but I could not wrap my head around it.. Here

  • 0

This should be simple but I could not wrap my head around it.. Here is how I am doing it now but it seems so wasteful.

There is a

List<string> committees

and

List<string> P.committees

I just want to see if one list has any strings that are contained in the other.

  List<Person> listFilteredCommitteesPerson = new List<Person>();

            foreach (Person p in listFilteredPerson)
            {
                foreach (string strCommittee in p.Committees)
                {
                       if (committees.Contains(strCommittee))
                       {
                           listFilteredCommitteesPerson.Add(p);
                       }
                }
            }

            listFilteredPerson = listFilteredCommitteesPerson;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T12:08:58+00:00Added an answer on June 10, 2026 at 12:08 pm

    For a boolean value:

    var match = 
       committees.Intersect(listFilteredPerson.SelectMany(p => p.Committees)).Any();
    

    If you want a collection of Person that have a match you can use:

    var peopleThatMatch = 
        listFilteredPerson.Where(p => committees.Intersect(p.Committees).Any());
    

    or:

    var peopleThatMatch = 
        listFilteredPerson.Where(p => p.Committees.Any(s => committees.Contains(s)));
    

    You might want to consider another collection type (e.g. HashSet<T>) for performance reasons if you have large collections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I assume this should be pretty simple, but could not get it :(. In
This should be very simple but I could not find an exhaustive answer: I
This should be simple task but i am not been able to find the
This should be simple, but I am still lost. There is a very similar
Seems like this should be simple, but powershell is winning another battle with me.
this should be simple to fix--but it's not because of IE7, or at least,
This question can be very simple but could not find the answer; I receive
This should be relatively simple for the MVC experts out there, but I'm still
This might be very simple..but could not figure out. I need to have a
This might be a very simple question, but I could not find the answer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.