I need to loop through an entire list of users, but need to grab 20 at a time.
foreach (var student in Class.Students.Take(20))
{
Console.WriteLine("You belong to Group " + groupNumber);
groupNumber++;
}
This way the first 20 will belong to Group 1, the second 20 to Group 2, and so on.
Is Take the correct syntax for this? I believe Take will take 20 then be done. Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…