I have .ToArray() of string and want to process that list in each 10 items group. I am pretty sure that I can use yield in this case but not sure how to.
I want loop through 100 items of .ToArray() and want to each group of 10 items and process.
Below is my code but not sure how to group each 10 items using yield.
caseNumberList is string .ToArray()
foreach (string commaString in ProcessGroup(caseNumberList, 10))
{
Console.Write(commaString); // 10 comma seperated items.
Console.Write(" ");
}
public static IEnumerable<string> ProcessGroup(Array[] number, int limit)
{
int itemNum = 0;
string caseNumbers = string.Empty;
//
// Continue loop until the exponent count is reached.
//
while (itemNum< limit)
{
caseNumbers = caseNumbers + number[itemNum];
yield return caseNumbers;
}
}
Please suggest.