I have a question about working of Random in C#. Say I want to call some function if variable i == 0. I have the following code:
Random rnd = new Random();
int i = rnd.Next(5);
if (i == 0){
myFunction();
}
So, I would call myFunction() one time per 5 launches of the program. And what if I had another code:
Random rnd = new Random();
for (int j = 0; j < 10; j++){
int i = rnd.Next(50);
if (i == 0){
myFunction();
}
}
Would I have the same result in the final? (calling of myFunction() one time per 5 launches of the program)
Aucun commentaire:
Enregistrer un commentaire