It often needs to divide the object list into smaller sub -lists according to the separators. In this example, we are interested in using the object index as a separatist to create a sub -list with specified size.
Consider the following example: divide
into multiple lists, each list contains three items in the original list in order. The expected output is:
List<someobject>
Original list: [A, G, E, W, P, S, Q, F, X, Y, I, M, C]
First of all, according to the indexing group project, and then converting each group into a list, we effectively divide the original list into the sub -list required. This technology provides a simple and clear solution for using the LINQ segmentation list.
The above is the detailed content of How to Split a List into Sublists of a Specific Size Using LINQ?. For more information, please follow other related articles on the PHP Chinese website!