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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:47:17+00:00 2026-06-17T13:47:17+00:00

I m in a situation where i need to find record from a generic

  • 0

I m in a situation where i need to find record from a generic list using its position, means need to find 1st 5th and 9th record , then 2nd 6th and 10th record and so on…

Situation is

A list of projects assigned to a List of Team,
So if we have 20 projects and 4 teams

then 1st project go to 1st team, 2nd go to 2nd team , 3rd go to 3rd team, 4th go to 4th team
then again 5th project go to 1st team

so its like

Projects              Team
1                     1
2                     2
3                     3
4                     4
5                     1
6                     2
7                     3
8                     4
9                     1
.
.

so now i want to run a Query on Generic List to get record for each team, so for first team record 1,5 and 9…. need to fetch.

Some thing like

 List<Project> lst = list (from Database)
 //For 1stTeam 
lst = lst.Index(1,5,9...);

//For 2nsTeam 
lst = lst.Index(2,6,10...);

Hope i clear my point.

  • 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-17T13:47:19+00:00Added an answer on June 17, 2026 at 1:47 pm

    First, this is not specific to generic lists.


    You have to create a new list, and then, one by one, add the items from the original list that you want in the new list. You can access single items at a given position via the indexer (square brackets).

    List<Project> lst = // list (from Database)
    
    List<Project> firstTeam = new List<Project>();
    firstTeam.Add(lst[1]);
    firstTeam.Add(lst[5]);
    firstTeam.Add(lst[9]);
    
    List<Project> secondTeam = new List<Project>();
    secondTeam.Add(lst[2]);
    secondTeam.Add(lst[6]);
    secondTeam.Add(lst[10]);
    

    Of course, if the items are distributed that regularly throughout the original lst, you can automatically determine the items:

    List<Project> firstTeam = new List<Project>();
    for (int i = 1; i < lst.Count; i += 4) {
        firstTeam.Add(lst[i]);
    }
    

    i.e. you loop over the original list, taking every 4th item.


    If the items to add to one of the teams are not distributed regularly throughout lst, you will have to add them one by one, but you might be able to make use of the shorter list initializer syntax:

    List<Project> firstTeam = new List<Project>() { lst[1], lst[5], lst[9] };
    

    Lastly, note that List<T> starts counting indices at zero, so the very first item is lst[0], not lst[1].

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

Sidebar

Related Questions

I have a situation where I need to find the value with the key
Situation: I need to make an imap client (using java mail api) that if,
I am using EF to access Sql azure. In one situation I need to
I have a situation where I need to dynamically build up a list of
I have a situation where I need to find the parent Window or WinForm
The situation: I need to convert our current development environment from Windows XP 32-bit to
I am in a situation where I need to find the Changes happened to
I have a situation where I need to find out the most recent entry
I am in a situation where I need to find out the level of
Situation: need to find which layer the user has touched. Problem: Apple says we

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.