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

  • SEARCH
  • Home
  • 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 6099867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:19:19+00:00 2026-05-23T13:19:19+00:00

I have a string comma separated list of some data. I have another list

  • 0

I have a string comma separated list of some data. I have another list of strings of keywords that i want to search for in the first list. I want to have returned to me the index of all the elements in the first list that do no contain any of the keywords in the second list. For example:

List 1:
Student,101256,Active
Professor,597856,Active
Professor,697843,Inactive
Student,329741,Active
Student,135679,Inactive
Student,241786,Inactive

List 2:
697843
241786

My query on List 1 should be, give me all the index of all the elements that do not contain any of the elements of list 2. Therefore, the return list of indices should be 0,1,3,4. Is there any way to accomplish this?

Thanks in advance!

Edit: This is my try:

List<int> index = list1
        .Select((s, i) => new { s, i })
        .Where(e => !list2.Contains(e.s))
        .Select(e => e.i).ToList();
  • 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-05-23T13:19:20+00:00Added an answer on May 23, 2026 at 1:19 pm

    You will need to reference System.Linq, this has now been edited to include the !Student filter

    var list1 = new List<string> {
      {"Student,101256,Active"},
      {"Professor,597856,Active"}, 
      {"Professor,697843,Inactive"}, 
      {"Student,329741,Active"},
      {"Student,135679,Inactive"},
      {"Student,241786,Inactive"}
    };
    var list2 = new List<string> {{"697843"}, {"241786"}};
    
    var result = list1
                 .Select((item,i)=> new {index=i,value=item})
                 .Where(item => !item.value.StartsWith("Student"))
                 .Where(item => !item.value.Split(',').Any(j => list2.Contains(j)))
                 .Select(item=>item.index)
                 .ToList();
    

    The first select extracts the index before filtering, the pre-edited version calculated the index after the filter and so was incorrect.

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

Sidebar

Related Questions

I have a comma separated list of strings like the one below. a,b ,c
I have the following data in my database (comma separated strings): word, test, hello
I have a comma separated value table that I want to read in Python.
If I have a std::string containing a comma-separated list of numbers, what's the simplest
I have a table that has a comma separated list of ids in one
I have a custom model binder that takes a comma separated list and cleans
I have some input that looks like the following: A,B,C,"D12121",E,F,G,H,"I9,I8",J,K The comma-separated values can
In Python, I have a string which is a comma separated list of values.
Hi I have a string of numbers separated by commas, 100,200,300,400,500 that I'm splitting
I have string like this /c SomeText\MoreText Some Text\More Text\Lol SomeText I want to

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.