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?

Ezzy
  • 1,423
  • 2
  • 15
  • 32
  • 3
    There are lot of similar question on SO, e.g. [How to split a list of integers to smaller chunks?](http://stackoverflow.com/questions/21043147/how-to-split-a-list-of-integers-to-smaller-chunks) or [Divide array into an array of subsequence array](http://stackoverflow.com/questions/3210824/divide-array-into-an-array-of-subsequence-array) – Sergey Berezovskiy Jan 11 '14 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. – David Jan 11 '14 at 12:50
  • Just look at the [linked answers](http://stackoverflow.com/a/419063/579344) using something along the lines of: `int chunkSize = 1+(list.Count-1)/numberOfChunks;` – johv Jan 11 '14 at 13:38

0 Answers0