Calculation of how many times I need to send a string

Asked

Viewed 35 times

0

I have a service that updates status of controller boards..

Only he only returns me only 22 records at a time. Then I need to take the number of items I want to update and send the amount of messages needed to update all.

Example: I have 5 cards. I send only one update request. I have 23 plates. I must send two requisitions (1 until 22, and the other with only 23)

Could someone help me do that?

  • 2

    try to explain your question a little better, please show your code c# in more detail.

  • 1

    It may be interesting to look at this topic later to help us better understand your future questions: http://answall.com/help/how-to-ask

  • @Rafaelspessotto Don’t thank answers with other answers. Simply comment, when you have the reputation needed for this.

1 answer

1


I’m not sure I understand the question, but maybe it’s something like this:

int numPlacas = CountPlacas();
const int numMaxRegistrosPorMensagem = 22;

int numMensagensNecessarias = (int)numPlacas  / numMaxRegistrosPorMensagem;

if((numPlacas % numMaxRegistrosPorMensagem) > 0)
    numMensagensNecessarias++;
  • Will additional messages only contain one card each? If yes, that’s correct...

  • Well observed @mutlei. I’ve already modified the code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.