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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:32:09+00:00 2026-06-08T12:32:09+00:00

Possible Duplicate: Split List into Sublists with LINQ I’m looking for some way to

  • 0

Possible Duplicate:
Split List into Sublists with LINQ

I’m looking for some way to split an enumerable into three enumerables using LINQ, such that each successive item in the input is in the next sublist in in the sequence. So input

{"a", "b", "c", "d", "e", "f", "g", "h"}

would result in

{"a", "d", "g"}, {"b", "e", "h"}, {"c", "f"}

I’ve done it this way but I’m sure there must be a way to express this more elegantly using LINQ.

var input = new List<string> {"a", "b", "c", "d", "e", "f", "g", "h"};
var list = new List<string>[3];

for (int i = 0; i < list.Length; i++)
    list[i] = new List<string>();

int column = 0;
foreach (string letter in input)
{
    list[column++].Add(letter);
    if (column > 2) column = 0;
}
  • 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-08T12:32:10+00:00Added an answer on June 8, 2026 at 12:32 pm

    This is what you are looking for:
    (Splits by columns) Modified based on the previous posts

    The key difference is in the group by, using mod instead of division.

    Also I made it generic so it gives you back the proper type (as opposed to “object typed” code). You can just use type inference with generics.

    public static IEnumerable<IEnumerable<T>> SplitColumn<T>( IEnumerable<T> source ) {
        return source
            .Select( ( x, i ) => new { Index = i, Value = x } )
            .GroupBy( x => x.Index % 3 )
            .Select( x => x.Select( v => v.Value ).ToList() )
            .ToList();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How do you split a list into evenly sized chunks in Python?
Possible Duplicate: How do you split a list into evenly sized chunks in Python?
Possible Duplicate: How do you split a list into evenly sized chunks in Python?
Possible Duplicate: How do you split a list into evenly sized chunks in Python?
Possible Duplicate: How do you split a list into evenly sized chunks in Python?
Possible Duplicate: How to split text without spaces into list of words? There are
Possible Duplicate: In Symfony2, can the validation.yml file be split into multiple files using
Possible Duplicate: most elegant way to return a string from List<int> I'm not sure
Possible Duplicate: How to best split csv strings in oracle 9i I have some
Possible Duplicate: CSV parser/reader for C#? I want to split the text using the

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.