what is the use of == -1 in this code? i can understand that adds 20 random numbers to an array but i can't understand why is it there? debug in Visual Studio didn't help to understand why. removing it returns can not implicitly convert "int" to "bool"
int[] Numbers = new int[20];
var counter = 0;
do
{
Random random = new Random();
var randomNumber = random.Next(1, 100);
//what is == -1?
if (Array.IndexOf(Numbers, randomNumber) == -1)
{
Numbers[counter] = randomNumber;
counter++;
}
} while (counter < 20);
Aucun commentaire:
Enregistrer un commentaire