I want to write a method that divides an array of strings into a n separate arrays, each of which is approximately the size I specify.
For example, if the array I want to divide had 23 elements, then if I specify 7 as the approximate number of elements:
1st array with 8 elements
2nd array with 8 elements
3rd array with 7 elements
Another example is if there were 100 elements and I specify 18 elements per array, then:
1st array 20
2nd array 20
3rd array 20
4th array 20
5th array 20
So far, I know that The function needs to return a list of string arrays, but I don't know what to do past that:
private List<string[]> divStrings(int ExpectedStringsPerArray,
string[] AllStrings)
{
// ...
}
The number of arrays will be
Math.Floor(AllStrings.Count()/ExpectedStringsPerArray)
How do I divide an array into separate arrays in C#?