Do they exist in C#? And if so, how are they coded?
The goal is to create a random number that is distinct from any number in a different array. I got the array to create six distinct numbers fairly easily, but this has me stumped. Here's what I have so far:
bonusNum needs to be distinct from any number in myNumbers. Any ideas?Code:private void GenerateRandomNumbers() { for (int i = 0; i < 6; i++) { myNumbers[i] = myRandom.Next(1, 46); for (int j = 0; j < i; j++) { if (myNumbers[i]==myNumbers[j]) { i = i - 1; } } } //fills the int array with random numbers bonusNum = myRandom.Next(1, 46); //creates the bonus number PopulateLabels(); //populates the labels }




Reply With Quote