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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:29:16+00:00 2026-05-12T09:29:16+00:00

CONTEXT I have a list of items (or arbitrary length). I’d like to group

  • 0

CONTEXT

  • I have a list of items (or arbitrary length). I’d like to group them in ‘chunks’ of a certain size
  • Example: I have 12 customers [0,1,2,3,4,5,6,7,8,9,10,11] and want to group themin chunks of 5 which would give [0,1,2,3,4] [5,6,7,8,9] [10,11]
  • NOTE: In reality I am not working with customers or monotonically increasing integers. I picked that just to simplify asking the question

MY QUESTION

How can I formulate a straightforward LINQ query (using query syntax) that performs this grouping?

BACKGROUND

  • I’m already familiar with how to use LINQ syntax for grouping by a value for example (to group sales by customer id), however I am at a loss how to express the ‘chunking’ cleanly/elegantly using LINQ. I am not sure if it is even possible in a straightforward way.
  • I can and have already implemented a solution in plain-old-C# without using the LINQ syntax. Thus, my problem is not being blocked on this question, but rather I am looking for ways to express it in LINQ (again cleanly and elegantly)
  • 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-12T09:29:16+00:00Added an answer on May 12, 2026 at 9:29 am

    You can group them by (index/chunkSize). Example:

        var result =
            from i in array.Select((value, index) => new { Value = value, Index = index })
            group i.Value by i.Index / chunkSize into g
            select g;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Context I have a list of items I also have a structure with s
In my application I have dropdown list with several items. I'd like to show
I have a list of items with some details that I would like to
I have a list view filled with data. I set up a context menu
I have a button which opens a context menu with a list of various
I have such xml: <bean id=conversionService class=org.springframework.context.support.ConversionServiceFactoryBean> <property name=converters> <list> <bean class=converters.AddressToStringConverter /> <bean
I have a class like this: public class Contest { List<ContestTeam> Teams { get;
I'm using C# 3.5 and EntityFramework. I have a list of items in the
I have list item with EditText in it, I dont know how many items
I have list item with EditText in it, I don't know how many items

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.