I have a program that will read the contents of a file into some sort of list or array. This list/array could contain any number of items. I need to split it into smaller groups, say of 50 items each and then do some processing on each item in each group.
List<string> stuffFromFile = new List<string>();
while ((line = fileReader.ReadLine()) != null)
{
stuffFromFile.Add(line);
}
I have been looking through some examples online about how to chunk stuff but to be honest, I don't really understand the examples and some of them seem overly complex. I just need something simple that will chunk/split/break the original list of items into groups of 50 and then let me iterate through each item in each group until the processing is complete.
The total number of items read in will most likely not be a number that I can divide evenly by 50 so most likely the last group may contain less than 50 items, but would still need to be processed just like the rest.
Can anyone help here? It sounds like it should be simple but I don't really know how to do it. I've seen example about using LINQ but I don't understand it either.