break up array into little arrays

前端 未结 6 748
南方客
南方客 2021-01-20 06:03

i am sending out email to a list of people. I have the list of recipients in array but the list can get up to 500 people. There is a limitation on the number of recipients

6条回答
  •  [愿得一人]
    2021-01-20 06:04

    Maybe ArraySegment works for you? You'd have to split it up manually though, but this is not hard in a loop.

    int recipient = 0;
    while (recipient < recipients.Count) {
      ArraySegment recipientSegment = new ArraySegment(recipients, recipient, Math.Min(50, recipients.Count-recipient));
      // build your message here, using the recipientSegment for the names
      recipient += 50;
    }
    

提交回复
热议问题