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 8438011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:35:27+00:00 2026-06-10T07:35:27+00:00

How can i select name in list? which is itself in list??? My struct:

  • 0

How can i select name in list? which is itself in list???

My struct:

public class Item
{
    int id;
    List<Name> names;
}

public class Name
{
    int id; 
    string name;
}

List<Item> Items;

code:

Items.Select(a => a.id = 1) //whats next 
  • 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-10T07:35:28+00:00Added an answer on June 10, 2026 at 7:35 am

    Assuming you want all of the names in a list, you can do:

    List<Name> matchingNames = Items.Where(a => a.id == 1).Select(a => a.names);
    

    Or if you want a list of the string names from the list, you can do:

    List<string> matchingNames = Items
        .Where(a => a.id == 1)
        .SelectMany(n => n.names)
        .Select(n => n.name)
        .ToList();
    

    Then, if you’re using my second statement, you can output a list in the format item, item, item by doing:

    string outputtedNames = string.Join(", " + matchingNames);
    

    EDIT: As requested in comments, here’s how you can get names by ID based on the Name ID:

    List<Name> matchingNames = Items
        .SelectMany(a => a.names)
        .Where(n => n.id == 1)
        .ToList();
    

    EDIT 2: To display name items and items that both have an ID of 1, try this:

    List<Name> matchingNames = Items
        .Where(a => a.id == 1)
        .SelectMany(a => a.names)
        .Where(n => n.id == 1)
        .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SELECT name FROM sys.databases -- this can list all database name in the server
I can select the first item in the div using $('.class:first') Now since I
I am trying to find the list of objects which can be replaced. Class
Hey I want to select records with name O'Neil, How can i do that
Can I name a custom column in the SELECT statement and reference that in
I have the following collection contract defined: [CollectionDataContract(Name = Centres)] public class Centres :
I have a Country list helper implemented just fine and can select quite happily.
For instance, in class Athlete I have: uint ID; string Name; Dictionary<string, string> statistics
I am displaying a list. The user can edit any item. I am displaying
You can select a part of a web page with the mouse. I know

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.