mercredi 25 novembre 2015

Shortening a for loop with if statements - C#

This is my current code:

for(int i = 1; i < 13; i + 4)
{
   do something
}
for (int i = 2; i <13; i + 4)
{
   do something
}

And so on for each value of i.

I would like my for loop to do the following without having to write out each individual value:

for(int i = 1; i < 13; i++)
{
    if(i is 1,5,9)
    {
       do something
    }
    if(i is 2,6,10)
    {
       do something
    }

The do something is for example, change text box text.

Thank you.

Aucun commentaire:

Enregistrer un commentaire