So I drew a blank as to whether creating a random number was 0 - (specific number) inclusive or exclusive. I created a simple program to test it quickly.
int number;
Random rand = new Random();
number = rand.Next(3);
textBox1.Text = number.ToString();
3 will never occur however zero does. I then add +1
int number;
Random rand = new Random();
number = rand.Next(3) + 1;
textBox1.Text = number.ToString();
Now ofcourse zero doesn't occur, but 3 does.
Why is it allowing 0 but not 3 in the first example? And why in the second does it allow 3? I understand why zero is exempt. Thanks :)
Aucun commentaire:
Enregistrer un commentaire