1

Let's say I have a List of the following:

a
b
c
d
e
f
g
h
i
j
k

Now I want to split this into, let's say two parts. There are 11 items in the list, so the first sublist would contain 5 items, and the second sublist would contain 6 items.

How would I go about to achieve this result?

3
  • 3
    There are lot of similar question on SO, e.g. How to split a list of integers to smaller chunks? or Divide array into an array of subsequence array Commented Jan 11, 2014 at 12:49
  • var subList1 = list.Take(5).ToList(); and var subList2 = list.Skip(5).ToList(); perhaps? You haven't defined any kind of pattern, so just break the values into the two lists as desired. Commented Jan 11, 2014 at 12:50
  • Just look at the linked answers using something along the lines of: int chunkSize = 1+(list.Count-1)/numberOfChunks; Commented Jan 11, 2014 at 13:38

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.