vendredi 20 octobre 2017

repeat and count a loop in an unordered sequence in C# [duplicate]

This question already has an answer here:

As you know "for" can generate ordered number while looping. I want to make a loop but with unordered numbers. As an example of what I need, see this:

for (int i = 0; i < 15; i++)
{
    // Do something with "i"...
}

this will repeat and count from 0 to 14 sequentially but suppose that I want it to repeat and count randomly between 0 and 14 like this:

13, 2, 7, 0, 14, 4, 6, 1, 8, 3, 5, 15, 9, 10, 12, 11

How can I do it?

Aucun commentaire:

Enregistrer un commentaire